The answer is: if he concludes the prayer with the imam after having prayed two rak‘ahs, there is no harm in that, because it is a voluntary prayer and he is not required to complete it. Yet if he completes it, that is better, due to the general wording of the Prophet’s ﷺ statement: “Whatever you catch of the prayer, pray; and whatever you miss, complete.” (1)
His statement, “except Maghrib,” means that it is not recommended to repeat it.
They reasoned that Maghrib is the witr of the daytime, as mentioned in the hadith (2), and it is not recommended to repeat witr, for there are not two witr prayers in one night. Likewise, there should not be two witr prayers in one day, and Maghrib is the witr of the daytime.
However, there is something questionable in this reasoning, for it may be said that the difference between Maghrib and the night witr is that Maghrib is repeated because of a newly occurring reason—namely, joining the congregation—and this is a clear distinction.
Moreover, the general wording of the Prophet’s ﷺ statement, “If you two have prayed at your lodgings, then come to a congregational mosque, pray with them,” (3) includes Maghrib, because the Prophet ﷺ did not exclude anything.
Accordingly, the sound view in this issue is that he should repeat Maghrib, because there is a reason for doing so: joining the congregation.
But should we say that, when the imam concludes the prayer, he should perform an additional rak‘ah so that the prayer becomes even-numbered, or may he conclude the prayer with the imam? There are two views on this.