I think we are missing to see the real reason behind the prohibition here.
In ancient times, crossing the ocean means travelling on the ship for months. But according to Manu Smriti and other similar texts, one should not recite Vedas on a ship.
Manu Smriti 4.120. Let him not recite the Veda on horseback, nor
on a tree, nor on an elephant, nor in a boat (or ship), nor on a
donkey, nor on camel, nor standing on barren ground, nor riding in a
So, while travelling on a ship one can not recite the Gayatri Mantra (which is a Vedic Mantra and which is also known as the mother of the Vedas). But without reciting the Gayatri one can not perform the Sandhya. So, basically one who is crossing the sea will not be able to perform Sandhya for months.
Now, Sandhya is a Nitya Karma for the Dvijas which he should be performing daily without fail. By failing to do so for months one will lose caste, becomes degraded as said in the verse given below:
Manu Smriti 2.103. But he who does not (worship) standing in the
morning, nor sitting in the evening, shall be excluded, just like a
Sudra, from all the duties and rights of an Aryan
But, for someone like Hanuman, who is/was endowed with super natural powers, crossing the sea wouldn't be a matter of even minutes. And, furthermore, he won't be boarding a ship, he will simply fly across the ocean.
So, the prohibition does not really apply to super natural beings like Hanuman.