Sayyiduna Abu Dharr (may Allah be pleased with him) narrates that the Prophet (peace and blessings be upon him) said: "Soon there will be rulers over you who will not lead the prayer at its proper time. Take heed! Offer the prayer at its proper time, then come to them. If they have already prayed, you have already offered your prayer; and if they have not prayed, pray with them, and it will be a voluntary prayer for you."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3643
Sayyiduna Yazid bin al-Aswad (may Allah be pleased with him) said: I was present with the Messenger of Allah (peace and blessings be upon him) for his Hajj, and I prayed the Fajr prayer with him in Masjid al-Khayf. When he (peace and blessings be upon him) had finished the prayer, he saw two men sitting at the back of the mosque who had not prayed with him (peace and blessings be upon him). He (peace and blessings be upon him) said: "Bring them to me." They were brought to him (peace and blessings be upon him), their bodies trembling with fear and alarm. He (peace and blessings be upon him) said: "Why did you not pray with us?" They said: O Messenger of Allah! We had prayed at our homes. He (peace and blessings be upon him) said: "Do not do so. When you have prayed at home and then come to the mosque while the congregation is praying, pray with them; it will be a voluntary prayer for you."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3644
Sayyiduna Yazid bin al-Aswad al-Khuza'i (may Allah be pleased with him) said: We prayed the Fajr prayer with the Messenger of Allah (peace and blessings be upon him) at Mina. When he (peace and blessings be upon him) had finished the prayer, he saw two men sitting at the back of the mosque. He (peace and blessings be upon him) had them called; they were brought, and they were frightened. He (peace and blessings be upon him) asked: "Why did you not offer the prayer with us?" They said: O Messenger of Allah! We have prayed at home before coming. He (peace and blessings be upon him) said: "Do not do so. When one of you has prayed at home and then catches the congregational prayer with the imam, let him pray it again with the imam; it will be a voluntary prayer for him."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3645
Jabir bin Yazid (may Allah be pleased with him) narrates from his father, Sayyiduna Yazid bin al-Aswad (may Allah be pleased with him), who said: I prayed with the Messenger of Allah (peace and blessings be upon him). When he (peace and blessings be upon him) finished the prayer with the salam, he saw two men behind the people. The Messenger of Allah (peace and blessings be upon him) called them, and they came in a state of fear and alarm. He (peace and blessings be upon him) asked: "Why did you not pray with us?" The two of them said anxiously: "O Messenger of Allah! We have prayed at our homes before coming." He (peace and blessings be upon him) said: "Do not do so; rather, when one of you has prayed at home and then comes to the mosque while the imam is leading the prayer, let him pray with him as well, and let him make the prayer he offered at home a voluntary prayer."
Ali (bin Umar) (may Allah have mercy on him) said: The students of al-Thawri (may Allah have mercy on him) differed from him (in this wording), and with them are the students of Ya'la bin Ata (may Allah have mercy on him), among them Shu'bah, Hisham bin Hassan, Sharik, Ghaylan bin Jami', Abu Khalid al-Dalani, Mubarak bin Fadalah, Abu Awanah and Hushaym (may Allah have mercy on them). They narrated from Ya'la bin Ata (may Allah have mercy on him) the same as the wording of Waki' (may Allah have mercy on him).
Ali (bin Umar) (may Allah have mercy on him) said: Hajjaj bin Artah (may Allah have mercy on him) narrated it from Ya'la bin Ata (may Allah have mercy on him), with his chain from the Prophet (peace and blessings be upon him), with similar wording. In it is: "The prayer will be voluntary for you, and the one you prayed at your homes will be the obligatory one."
Hajjaj bin Artah erred in its chain, even if he was right in its text; the correct version is the narration of the group. Al-Shafi'i (may Allah have mercy on him), in his earlier works (al-Qadim), mentioned the argument of those who argued from the hadith of Ya'la bin Ata, then said: This is a majhul (unknown) chain. He said that, and Allah knows best, only because Yazid bin al-Aswad has no narrator other than his son Jabir bin Yazid, and Jabir bin Yazid has no narrator other than Ya'la bin Ata. Yahya bin Ma'in and a group of the imams considered Ya'la bin Ata thiqah (trustworthy), and this hadith has corroborating reports that have already been mentioned, so arguing from it and from its corroborating reports is sound. And Allah knows best.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3646