Praise be to Allah.
Shaykh Ibn ‘Uthaymeen was asked about that and he said:
When a person is in the bathroom, he should say the name of Allaah in his heart and not utter it aloud. So if you are in this situation, do this. The more correct opinion is that saying the name of Allaah is not obligatory, rather it is mustahabb, but you should not pay attention to waswaas (insinuating whispers from the Shaytaan) or be negligent.