The Messenger of Allah ﷺ said, "When you see a man frequenting the mosque, bear witness to his faith, for Allah the Exalted says, "The mosques of Allah are only maintained by those who believe in Allah and the Last Day, establish prayer, and give zakat" [Tawbah 9:18]."
حدثنا ابن أبي عمر حدثنا عبد الله بن وهب عن عمرو بن الحارث عن دراج أبي السمح عن أبي الهيثم
قال رسول الله ﷺ إذا رأيتم الرجل يتعاهد المسجد فاشهدوا له بالإيمان فإن الله تعالى يقول {إنما يعمر مساجد الله من آمن بالله واليوم الآخر وأقام الصلاة وآتى الزكاة} الآية
[Its isnad is daif] Ibn Khuzayma related it, no. 1502, from the hadith of Ibn Wahb, and Ibn Majah, no. 802, through another route from Amr bin Harith with the same wording, as will come later, no. 3093. Ibn Hibban graded it sahih, no. 310, and Hakim, 2/332, and Dhahabi agreed with him. See no. 2033 for its defect.