If the Imam mistakenly stands up for 5th Rakaâ€™at in a Salaat of 4 Rakaâ€™at and someone joins the Salaat in that Rakaâ€™at, then the Salaat of this person will be invalidated regardless of whether the Imam sat for Tashahud, etc. in the 4th Rakaâ€™at or not.
If the Imam has sat for Tashahud in the 4th Rakaâ€™at, then this person is joining the Salaat after the Obligatory Salaat has ended. If the Imam has not sat down for Tashahud, etc. in the 4th Rakaâ€™at, then with the prostration of the 5th Rakaâ€™at, the Salaat of the Imam and all those who follow him will be invalid. Thus, the Salaat of this person will not be correct in any case.
As mentioned in Radd Ul Muhtaar and Al Bahr Ur Raaiq Sharh Kanz Ud Daqaaiq.
And Allah Most High knows best.
Mufti Syed Ziauddin Naqshbandi Qadri
[Professor, Islamic Law, Jamia Nizamia,
Founder-Director, Abul Hasanaat Islamic Research Center]