Sayyiduna Ata bin Abi Rabah (may Allah have mercy on him) narrates that (in the early days of Islam) when a person would come while the Messenger of Allah ﷺ was leading the prayer and some rak‘ahs had already passed, the person would ask another worshipper (which rak‘ah is being performed). When he was informed, he would quickly perform the missed rak‘ahs and then join the Prophet ﷺ. Sayyiduna Ibn Mas‘ud (may Allah be pleased with him) came and joined the congregation without asking how many rak‘ahs had been performed. When the Prophet ﷺ finished the prayer with salam, Ibn Mas‘ud (may Allah be pleased with him) stood up and completed the remainder of his prayer. The Prophet ﷺ said: “O Companions! Ibn Mas‘ud (may Allah be pleased with him) has adopted a way for you, so you should do the same.” (That is, join the imam in whatever state you find him, and complete the remaining prayer afterwards, instead of each person completing his missed rak‘ahs first and then joining, which would result in some being in qiyam, some in ruku‘, and some in sujud—there should be order and discipline.) The narrator Sufyan says that, except for ‘Amr bin Dinar, the narrators have mentioned the name of Sayyiduna Mu‘adh (may Allah be pleased with him) instead of Sayyiduna Ibn Mas‘ud (may Allah be pleased with him). (That is, the companion was not Ibn Mas‘ud (may Allah be pleased with him), but rather Mu‘adh bin Jabal (may Allah be pleased with him).)
Hadith Referenceالسنن المأثورة / باب ما جاء في صلاة الخوف / 65