Yahya bin Maymun al-Hadrami relates that Sayyiduna Sahl bin Sa'd al-Sa'idi (may Allah be pleased with him) came and stood by us while we were in the mosque. Sahl (may Allah be pleased with him) said: I heard the Messenger of Allah (peace and blessings be upon him) say: "Whoever sits in the mosque waiting for the prayer is counted as being in prayer."
Hadith Referenceالمعجم الكبير للطبراني / باب السين / 5988
Yahya bin Maymun al-Hadrami relates: I was sitting in the mosque when Sayyiduna Sahl bin Sa'd (may Allah be pleased with him) passed by me and said: "Shall I not tell you a hadith that I heard from the Messenger of Allah (peace and blessings be upon him)?" I said: "Certainly." He said: I heard the Messenger of Allah (peace and blessings be upon him) say: "Whoever is in the mosque waiting for the prayer is counted as being in prayer."
Hadith Referenceالمعجم الكبير للطبراني / باب السين / 5989