Joining the prayer when the imam is in the final tashahhud
We entered a mosque as a group and we found that the imam was in the second tashahhud. Can we join him at that point in the prayer, or do we perform a separate prayer, as some of us said that the prayer cannot be achieved without praying a complete raka‘ah [with the imam].
The majority of legists agree that one achieves the congregational prayer when one participates with the Imam in any part of it at any point, even if it is the end of the second tashahhud before the final closing salutation (salam).
Based on this principle and the circumstances stated in the question:
It is permissible for you to join the imam in the last tashahhud, and according to the majority of legists you will have the reward of the congregational prayer.
And Allah the Almighty knows best .