Ruling regarding Tashahhud when joining the Imam during the last Rak`ah of the Maghrib Prayer

A: If you catch up with the last Rak‘ah of Maghrib Prayer behind the Imam, you should stand, after the Imam has recited Taslim (salutation of peace ending the Prayer), to offer one Rak‘ah and then sit down to recite the first Tashahhud. Afterwards, you should stand up to offer the third Rak‘ah, sit down to recite the last Tashahhud, and finally recite Taslim.May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.