Al-Muwaffaq, al-Majd, Shaykh al-Islam, and Ibn al-Qayyim stated: Whatever a worshipper joins with the imam is the beginning of his prayer, and what he performs afterward is its end. This is what the command to “complete it” entails; it also accords with the law and with sound analogy, and it is the view held by a number of the Companions.
Shaykh ʿAbd al-ʿAzīz b. Bāz said: The soundest opinion among the scholars is that whatever the latecomer (masbūq) catches with the imam counts as the start of his prayer, and what he makes up is its conclusion. The evidence is the Prophet’s ﷺ words: “When you come to the prayer, walk calmly and with dignity; whatever you catch, perform, and whatever you miss, complete” (al-Bukhari 609; Muslim 603).
The well-known position of the three other schools—those of Abū Ḥanīfah, Mālik, and Aḥmad—is that whatever the latecomer joins with the imam constitutes the end of his prayer and what he makes up is its beginning. The first view, however, is the stronger one, and Allah knows best.