Can You Pray ‘Isha behind Someone Praying Tarawih or Witr?
Question

I missed ‘Isha prayer once and caught up with the imam in the prayer of Witr, so I followed him. He made du’a then finished the Witr prayer, so I stood up and continued my ‘Isha. Is what I did permissible? The rak’ah I prayed behind the imam is considered Witr or a part of ‘Isha prayer? What should I do in this case?
Praise be to Allah.Is praying ‘Isha behind someone praying Tarawih or Witr valid?
Your praying `Isha behind someone who was praying Tarawih or Witr is valid according to the more correct of the two scholarly opinions. This issue is known to the jurists as the prayer of one who is offering an obligatory prayer behind one who is offering a nafl prayer.
 Offering obligatory prayer behind one who is offering a nafl prayer
Ibn Qudamah (may Allah have mercy on him) said in al-Mughni (2/30): 
“There are two reports concerning the prayer of one who is offering an obligatory prayer behind one who is offering a nafl prayer , one of which is that it is not valid. This view was favoured by most of our companions, and this is the view of al-Zuhri, Malik, and ashab al-ray, because the Prophet (peace and blessings of Allah be upon him) said: “The imam is appointed to be followed, so do not differ from him.” Agreed upon.  
The other view is that it is permissible. This is the view of al-Shaafi`i and Ibn al-Mundhir. This is more correct, because of the report narrated by Jabir ibn ‘Abd-Allah that Mu’adh would pray with the Messenger of Allah (peace and blessings of Allah be upon him), then go back and lead his people in that prayer. (Agreed upon) 
And it is narrated that the Prophet (peace and blessings of Allah be upon him) led a group of his Companions in the fear prayer, and did two rak`ahs then said the salam, then he led the other group in two rak`ahs then said the salam. (Narrated by Abu Dawud) The second two rak`ahs were nafl for him, but he was leading people who were offering the obligatory prayer. 
As for the hadith that they quote, what it means is: Do not differ from the imam in his actions, based on the fact that he said: “When he bows, then bow, and when he rises from bowing then rise from bowing, and when he prostrates then prostrate, and if he prays sitting down then you should all pray sitting down.” 
The scholars of the Standing Committee for Issuing Fatwas were asked: What should be done if a person comes after `Isha prayer and the prayer has ended, and the imam gets up to pray Tarawih. Should he follow the imam with the intention of praying `Isha, or should he get up and pray by himself or with a congregation if there is one? 
They replied: 
“It is permissible for him to pray `Isha in congregation with one who is praying Tarawih, then when the imam says the salam after two rak`ahs, the one who is praying `Isha behind him should stand up and pray two more rak`ahs in order to complete ‘Isha prayer.” (Fatawa al-Lajnah al-Daimah, 7/402) 
Shaykh Ibn Baz (may Allah have mercy on him) was asked: If a Muslim comes to the mosque and finds the congregation praying Tarawih, and he has not prayed `Isha, should he pray with them with the intention of praying `Isha? 
He replied: 
“There is nothing wrong with him praying with them with the intention of praying ‘Isha , according to the more correct of the two scholarly opinions. When the imam says the salam, he should stand up and complete his prayer.” (Fatawa al-Shaykh Ibn Baz, 12/181) 
The rak`ah that you prayed with the imam will not be counted as Witr for two reasons: 

1 – You started to pray with the intention of praying `Isha, so it is a rak’ah that is counted as part of ‘Isha, and you have to complete the rest of the prayer after the imam says the salam. 
2 –  cannot be valid unless one has finished ‘Isha, because of the report narrated by Imam Ahmad (23339), that the Prophet (peace and blessings of Allah be upon him) said: “Allah has added a prayer for you, and it is Witr, so pray it between ‘Isha and Fajr.” (Classed as sahih by al-Albani in Silsilat al-Ahadith al-Sahihah 9108). 

To sum up, what you did is valid and we ask Allah to accept it from you. 
And Allah knows best.