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]