وَجَاءَتْ تِلْكَ الطَّائِفَةُ، فَيُصَلِّي بِهِمُ الْإِمَامُ رَكْعَةً وَسَجْدَتَيْنِ، وَتَشَهَّدَ وَسَلَّمَ
Translation: The other group arrives, and the imam prays one rakah and two prostrations with it, then recites tashahhud and ends with salam.
The imam has completed two rakahs in total: one with each group, so he recites tashahhud and gives salam.
The second group joined only for the imam’s final rakah and must still complete one of its own.