In the Name of Allah, the Most Gracious, the Most Merciful.
As-salāmu ‘alaykum wa-rahmatullāhi wa-barakātuh.
One who misses the Esha Salat should first perform his Esha Salat individually.
If he missed only a few Rakats of Taraweh Salat then he can first perform those missed Rakats and then join the Imam for the remainder of the Taraweh Salat and for the Witr Salat. Otherwise he should join the Imam for Taraweh and Witr Salat. After the Witr Salat he should complete the missed Rakats of Taraweh.[1]
And Allah Ta’āla Knows Best
Mufti Saeed Ahmed Golaub
Islamic Solutions
Jamaica
References
[1]:(التَّرَاوِيحُ سُنَّةٌ) مُؤَكَّدَةٌ لِمُوَاظَبَةِ الْخُلَفَاءِ الرَّاشِدِينَ (لِلرِّجَالِ وَالنِّسَاءِ) إجْمَاعًا
(وَوَقْتُهَا بَعْدَ صَلَاةِ الْعِشَاءِ) إلَى الْفَجْرِ (قَبْلَ الْوِتْرِ وَبَعْدَهُ) فِي الْأَصَحِّ، فَلَوْ فَاتَهُ بَعْضُهَا وَقَامَ الْإِمَامُ إلَى الْوِتْرِ أَوْتَرَ مَعَهُ ثُمَّ صَلَّى مَا فَاتَهُ. الدر المختار وحاشية ابن عابدين (رد المحتار) (2 / 43)