Reference: Sharh ‘Umdatil-Fiqh – Tape No.7, Question No.45
Question: A man entered the masjid, and the imaam had just arisen from the rukoo’ [position], and [as such] he does not know whether it is the final rak’ah or not. The question is, should he join the imaam [in congregation], or should he wait so he can confirm for sure?
Response: If he does not know, then he should join the imaam [in congregation]. If, however, he knows it is the final rak’ah and he [also] knows others will [shortly] enter the masjid to pray, then he should wait for them so he can pray [in congregation] with them. So when the imaam completes the prayer, they can then pray [together in their congregation]. If no-one can tell him it’s the last rak’ah – or he himself does not know, then he should join the imaam [in congregation], otherwise the time will pass and he will miss out on the reward for joining the imaam [in congregation].