Mughirah reported that he was with the Messenger of Allah ﷺ on a journey when the Prophet ﷺ went off to relieve himself. The time for prayer arrived, so they began the prayer with Abdul-Rahman leading them. The Prophet ﷺ then came and prayed one rakah behind the people. When Abdul-Rahman gave the closing salutation, the Prophet ﷺ said, "You have done right," or "You have done well."
حدثنا هيثم بن خارجة قال أبو عبد الرحمن يعني عبد الله وسمعته أنا من الهيثم بن خارجة حدثنا رشدين عن عبد الله بن الوليد أنه سمع
أنه كان مع رسول الله ﷺ في سفر فذهب النبي ﷺ لحاجته فأدركهم وقت الصلاة فأقاموا الصلاة فتقدمهم عبد الرحمن فجاء النبي ﷺ فصلى مع الناس خلفه ركعة فلما سلم قال أصبتم أو أحسنتم
Its chain of transmission is daif, due to the weakness of Rushdin bin Saad. Haytham bin Kharija the Khurasani, the hadith master, is trustworthy, and Ahmad, his son Abdullah, and Bukhari all narrated from him. Abdullah bin Ahmad said, "When my father approved of someone and considered him trustworthy, he would narrate from him while he was still alive, and he narrated to us from Haytham bin Kharija while he was still alive." Abdullah bin Walid bin Qays, Ibn Akhram Tujaybi Misri, is trustworthy, mentioned by Ibn Hibban among the trustworthy narrators.As for the story itself, it is established through the hadith of Mughira bin Shuba, narrated by Ahmad, Bukhari, and Muslim, see Muntaqa 1400.