Every creature within the area of the Black Tentacles spell that loses their grapple check is grappling. So the combat modifier for ranged attacks versus a grappling creature ("Roll randomly to see which grappling combatant you strike, defender loses Dex bonus to AC") applies.
Only if the tentacles were incorporeal, illusory, telekinetic or of some other nature that would let a ranged attack simply pass through them an attacker wouldn't have to roll randomly. But considering the physical nature of the conjured tentacles (rubbery, black, 10 feet long) this does not seem to be the case at all.
The fact that the tentacles are "immune to all types of damage" doesn't mean that they can't be hit, they just can't be hurt. If you roll randomly and strike a tentacle the attack is wasted.