Ruling on speaking in the bathroom
Question

I heard that speaking in the bathroom is not good, but does this ruling apply if I am talking to myself in the bathroom when relieving myself?
Praise be to Allah.If speaking in the bathroom happens when one is relieving oneself, it is not allowed, and it is contrary to good manners and dignity.
An-Nawawi (may Allah have mercy on him) said:
The scholarly view that it is disliked (makruh) to speak when relieving oneself is one on which there is consensus.
Our companions said: All types of talk are regarded as equally disliked, but there is an exception in cases of necessity, such as if one sees a blind person about to fall into a well, or sees a snake and the like heading towards a human or other creature whose life is to be protected. It is not disliked to speak in these cases; rather it is obligatory in most such cases.
End quote from al-Majmu`, 2/88.
But speaking in the bathroom happens at a time other than when relieving oneself, there is no text to indicate that it is not allowed, and in principle it must be permissible.
Shaykh Ibn `Uthaymin (may Allah have mercy on him) was asked:
What is the ruling on speaking in the toilet before starting to relieve oneself?
He replied:
There is nothing wrong with that, especially if there is a need for it, because there is no clear prohibition on that, unless two men are defecating and they sit next to one another and talk to one another. This is what is prohibited. As for merely speaking in a place where people relieve themselves, there is no prohibition on that.
End quote from Liqa’ al-Bab al-Maftuh, 171/11).
For more information, please see the answer to question no. 297964.
And Allah knows best.