It was narrated from Abu Sa'eed al-Khudri that: The Messenger of Allah said: "No two people should converse while relieving themselves, each of them looking at the private parts of the other, for Allah, the Mighty and Sublime, hates that". (Da'if) Other chains with similar wording.
Additionally, this hadith reminds us to be mindful of our surroundings at all times; even if no one else can see or hear us, Allah still knows what we are doing and saying. We should strive to always act with respect towards others regardless of whether they are present or not; this will help ensure that our actions will be pleasing in His sight.