Praise be to Allah.
An-Nasaa’i 91364), at-Tirmidhi (806), Abu Dawood (1375) and Ibn Maajah (1327) narrated that Abu Dharr said: We fasted Ramadan with the Messenger of Allah (blessings and peace of Allah be upon him). When there were seven nights of the month left, he led us in praying qiyaam until approximately one-third of the night had passed. Then when there were six nights left he did not lead us in praying qiyaam. Then when there were five nights left, he led us in praying qiyaam until almost half the night had passed. We said, O Messenger of Allah, would that we had offered naafil prayers throughout the whole night. He said, “If a man prays with the imam until he finishes, it will be counted for him [as if] he spent the whole night in prayer.” Classed as saheeh by al-Albaani in Saheeh an-Nisaa’i.
This reward that is mentioned in the hadith is attained by praying behind the imam from the beginning of his prayer until he finishes . It cannot be attained by catching up with four rak‘ahs with him only, at the end of his prayer, even if the imam is going to leave after that.
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) was asked: If during Ramadan a man prays at the beginning of the night in one mosque and at the end of the night in another mosque, will the reward be like that?
He replied: The Prophet (blessings and peace of Allah be upon him) said: “Whoever prays with the imam until he finishes – that is, Taraaweeh in Ramadan – it will be recorded [as if] he spent the night in prayer.”
But if he prays with the first imam, then he prays with the second imam, it cannot be said that he has prayed with the imam until he finished, because he divided his prayer between two men (two imams).
So it may be said to him: Either pray qiyaam with this one from the beginning of the night until the end, or miss out on the reward." (Al-Liqa’ al-Maftooh 176/16).
But if your work circumstances do not allow you to pray all of Taraaweeh in one mosque, then there is the hope that you will have the reward for your intention, accompanied by what you are able to do of actions. We ask Allah to accept good deeds from us and from you.
And Allah knows best.