The Prophet (ﷺ) said, "When you come to the prayer, come with calmness and dignity; whatever you catch, pray it, and whatever you missed, complete it." So the latecomer joins the imam in whatever position he finds him, and the portion he prays with the imam counts as the beginning of his prayer, not the end; after the imam gives the tasleem, he stands and makes up the rak'ahs he missed. According to the majority, whoever catches the imam in rukū' (bowing) before he rises has caught that entire rak'ah, based on the practice of Abū Bakrah reported in al-Bukhārī. One who misses the rukū' has missed that rak'ah and does not count it.
Q&A · Prayer
How does a latecomer (masbuq) who joins the congregation after it has started complete his prayer?
Evidence — the daleel
Sahih Muslim 602 ṢaḥīḥSahih al-Bukhari 636 ṢaḥīḥSahih al-Bukhari 783 Ṣaḥīḥ
On deen2u
Informational, not a personal fatwa. Consult a qualified scholar for rulings on your situation.