All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
If the Imaam offers Tasleem before completing his prayer, then he returns to complete it, the late joiners should follow the Imaam then complete what remains of their prayer.
Since you have intended to pray individually and prayed one Rak‘ah before returning to follow the Imaam once more then you returned to follow him again, this Rak‘ah is invalid because it actually occurred during the prayer of the Imaam. You should have performed it after the Imaam offers Tasleem and prostrates himself for forgetfulness. Therefore, you should repeat the prayer because you only performed three Rak‘ahs due to the invalidity of the Rak‘ah you performed alone.
Allaah Knows best.