ANSWER:

What you did was wrong. It’s not permissible to sit down when you have already stood up for the rakah.

You should have continued your 3rd rakah and after completing the final tashahhud, before salam you should have made sujood as sahu for missing the 1st tashahhud and then made salam.

Sujood As Sahu (Prostrations of Forgetfulness)

In isha prayer i made a mistake i joined imam at 4th rakah after the salam i have to stand up and pray my 2nd rakah and sit at tashahhud but i forgot to sit at tashahhud and stand up straight for my 3rd rakah after standing i realised i forgot to sit so i sat down did tashahhud and completed my 3rd and 4th rakah at the end i did sajda sahu before salam is my prayer valid

Prayer |