Muhajir bin Qunfud reported,

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."

Azami 10797

Sahih

عن المهاجر بن قنفذ

أنه أتى النبي ﷺ وهو يبول فسلم عليه، فلم يرد عليه السلام حتى توضأ، ثم اعتذر إليه فقال: إني كرهت أن أذكر الله عز وجل إلا على طهر. أو قال: على طهارة.

الأعظمي 10797صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Supplications, remembrances, and prayer upon the chosen Prophet ﷺ
Chapter
Supplications
Section
Disliking to mention Allah without being in a state of purity
Numbering
Jami al-Kamil 10797 (2nd edition)
Azami 10797