All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
The scholars of Fiqh have different opinions on the ruling of Sujood as-Sahw (prostration of forgetfulness) if someone joins the prayer late and the Imaam does Sujood as-Sahw after making Tasleem. In summary, the Hanafi and Hanbali scholars are of the view that if someone joins the prayer late, he is obliged to follow the Imaam in Sujood as-Sahw before standing to make up (for the Rak’ahs that he missed); whereas the Maaliki and Shaafi'i scholars are of the view that he should first stand to make up the Rak’ahs that he missed and when he completes his prayer, he should make Sujud as-Sahw. The issue is a matter of personal scholarly judgment (Ijtihaad), so if one follows either of the two opinions, then he has indeed acted in accordance with a considerable opinion.
Ibn Qudaamah said in Al-Mughni: “If the person led in prayer has joined the prayer late and the Imaam made a mistake before that person joins the prayer, then he has to follow the Imaam in Sujood as-Sahw, whether it is before Tasleem or after it. ‘Ataa’, Al-Hasan, An-Nakha'i, Ash-Sha’bi, Abu Thawr and the Hanafi scholars are reported as saying so. Ibn Seereen and Is-haaq said that he should first make up whatever he missed and then do prostrations (for Sahw). The view of Maalik, Al-Awzaa'i, Al-Layth and Ash-Shaafi’i is like ours in case the Imaam did prostration before Tasleem, and their view is like Ibn Seereen in case the Imaam did prostration after Tasleem. Ahmad is also reported as saying so as stated by Abu Bakr in Zaad Al-Musaafir.” [End of quote]
The Hanbali scholars elaborated on the issue of whether the person who joins the prayer late should stand to make up for whatever he missed before the prostrations (for Sahw) with the Imaam. In summary, if the Imaam prostrates before the person who joined prayer late stands upright, he has to return (to do the prostrations), and if the Imaam does the prostrations after the person who joined prayer late stands upright, then he does not return; if he returns, however, then this is acceptable from him; but if the person who came late to prayer has started to recite the Faatihah, then it is forbidden for him to return; rather, he continues his prayer and then he prostrates (for Sahw) after Tasleem. If he returns while knowing that it is forbidden for him to do so, then his prayer is invalid.
Allaah Knows best.