A man entered the mosque while the Messenger of Allah ﷺ was seated in one corner of it. He prayed, then came and greeted him.The Messenger of Allah ﷺ replied, "And upon you. Go back and pray."He then mentioned the hadith in its full length.
حدثنا إسحق بن منصور أخبرنا عبد الله بن نمير حدثنا عبيد الله بن عمر عن سعيد المقبري
دخل رجل المسجد ورسول الله ﷺ جالس في ناحية المسجد فصلى ثم جاء فسلم عليه فقال رسول الله ﷺ وعليك ارجع فصل فذكر الحديث بطوله
Sourcing note. Bukhari also narrated it in the Book of Seeking Permission, in the chapter "One Who Replies by Saying, 'And Peace Be Upon You,'" hadith no. 6251, from Ishaq bin Mansur, with the same wording. It also has another route in Muslim, hadith no. 397, and in Bukhari, hadith no. 757.