Sayyiduna Abu Dharr (may Allah be pleased with him) said: The Messenger of Allah (peace and blessings be upon him) said: "O Abu Dharr! What will you do when there are rulers over you who perform the prayer at its last time?" I asked: What do you command me to do? He said: "Perform the prayer at its (initial) time, and then pray with them with the intention of a voluntary prayer." Imam Darimi (may Allah have mercy on him) said: Abdullah bin As-Samit is the nephew of Abu Dharr.
Hadith Referenceسنن دارمي / من كتاب الصللاة / 1262
From both these hadiths, it is understood that the prayer should be performed at its earliest prescribed time. If the imam or the leader delays it and performs it at the end of its time, then if one is present in the mosque, one should repeat the prayer with them, intending it as a voluntary (nafl) prayer.
In a narration of Sahih Muslim, it is mentioned that one should not say, "I have already performed the prayer," because there is a fear of causing discord (fitnah) by doing so.