begins the obligatory prayer alone, then notices a group who have entered to pray in congregation, may he discontinue it in order to join the congregation?
The answer is: Yes, he may do so. For he has not deliberately disobeyed Allah and His Messenger ﷺ by discontinuing the obligatory prayer; rather, he has discontinued it in order to perform it in a more complete manner. In reality, this serves the interest of the prayer itself. Therefore, the scholars have stated that in such a case, he may discontinue it for the sake of what is better.
Perhaps supporting evidence for this may be found in the story of the man who came to the Prophet ﷺ in Mecca and said: “O Messenger of Allah, I vowed that, if Allah granted you the conquest of Mecca, I would pray two rak‘ahs in Jerusalem.” He said, “Pray here.” The man repeated his question two or three times, and he said, “As you wish.” (1) Thus, he permitted him to pray in Mecca, because it was better, even though going to Jerusalem entailed a degree of hardship and exertion.
Yet deliberately seeking hardship in worship is not prescribed, due to the saying of Allah Most High: “Why should Allah punish you if you are grateful and believe?” [al-Nisaʾ 4:147] However, if an act of worship can only be performed with hardship, then it is better. This is an issue to which one should pay attention: is it better to seek hardship in worship or ease?
The answer is that ease is better. But if an act of worship can only be performed with hardship and difficulty, then carrying it out despite that hardship and difficulty brings a greater reward. Hence, the Prophet ﷺ said concerning that by which Allah raises degrees and expiates sins: