He came to the Prophet ﷺ while he was urinating and greeted him with the salaam, but the Prophet did not respond until he had performed ablution. Then he apologized to him, saying, "I disliked mentioning Allah
except in a state of purity." Or he said, "in a state of cleanliness."
أنه أتى النبي ﷺ وهو يبول فسلم عليه، فلم يرد عليه السلام حتى توضأ، ثم اعتذر إليه فقال: إني كرهت أن أذكر الله عز وجل إلا على طهر. أو قال: على طهارة.
Abu Dawud (17) — this is his wording — Nasai (38), and Ibn Majah (350) narrated it. Ibn Khuzayma (206), Ibn Hibban (803), and Hakim (1/167) graded it sahih. All of them narrated it through the route of Saeed bin Abu Aruba, from Qatada, from Hasan, from Hudhayn bin Mundhir Abu Sasan, from Muhajir bin Qunfudh bin Umayr, who mentioned it.Its chain of transmission is sahih.