Two scenarios:
1 - A person has a choice of either being the 10th person for a minyan at either a shul or a mourner's home. Where should he go? Assume that one of these 2 places count on him to form the minyan. Without him, they won't get anyone else.
2 - A mourner cannot get a minyan at his home unless the minyan (consisting of exactly 10 people) from shul would all come to his home. Should these 10 people daven in the shul, or should they all form a minyan in the mourner's home?
These people cannot daven at both places because, I believe, there is a rule that at least 6 people should not have previously davened in order to be able to repeat the Amidah.
(Source: Kitzur S.A. סימן כ - דין חזרת תפלת השליח צבור)
אֵין אוֹמְרִים תְּפִלַּת שְׁמֹנֶה עֶשְׂרֵה בְּקוֹל, אֶלָּא אִם כֵּן יֵשׁ לְכָל הַפָּחוֹת שִׁשָּׁה אֲנָשִׁים, שֶׁהֵם רֹב מִנְיָן שֶׁהִתְפַּלְּלוּ עַתָּה.
The main concern - Does davening in a shul have the highest priority? If so, why?