The Messenger of Allah ﷺ said, "It is not lawful for anyone to look into the inside of another's house until he asks permission. If he looks, he has effectively entered. Nor should anyone lead a people in prayer and single himself out with a supplication to their exclusion. If he does so, he has betrayed them. And no one should stand for prayer while needing to relieve himself."
حدثنا علي بن حجر حدثنا إسمعيل بن عياش حدثني حبيب بن صالح عن يزيد بن شريح عن أبي حي المؤذن الحمصي
عن رسول الله ﷺ قال لا يحل لامرئ أن ينظر في جوف بيت امرئ حتى يستأذن فإن نظر فقد دخل ولا يؤم قوما فيخص نفسه بدعوة دونهم فإن فعل فقد خانهم ولا يقوم إلى الصلاة وهو حقن
[Its chain of transmission is hasan]. Abu Dawud narrated it in the Book of Purification, chapter "Should a man pray while holding back the urge to urinate?", hadith no. 90, from the hadith of Ismail bin Ayyash, whom Ibn Khuzayma criticized, hadith no. 63/3, before hadith no. 1630, and Baghawi graded it hasan, and he was correct in that.There is also a hadith on this subject from Abu Hurairah [Abu Dawud, no. 91] and from Abu Umama [Ahmad 250/5, 260, 261], through the narration of Muawiya bin Salih.The hadith of Yazid bin Shurayh from Abu Hurairah was narrated by Hakim 168/1, who graded it sahih, and Dhahabi agreed with him. The hadith of Yazid from Abu Hayy from Thawban was narrated by Abu Dawud, hadith no. 90.