Sources and justifications:
In the Shulchan Aruch (Orach Chaim 263:15), it is written that anyone who delayed the Mincha prayer on the eve of Shabbat until the congregation has received Shabbat should not pray Mincha in that synagogue, but should go outside and pray Mincha as on a regular day. And its origin is in Trumot HaDeshen, as mentioned in Beit Yosef.
Here is the reason why one cannot pray there: it is because one should not perform weekday work in front of them, as explained in the Mishná Brurá (there). And, on the other hand, just as a Jew from the Land of Israel should not perform work on the second day of Yom Tov in the presence of Jews from the diaspora due to disdain [ziluta], as mentioned in the Shulchan Aruch (Orach Chaim 496), here too, if he performs work in their presence, it will be considered disdain. And for this reason, it seems that it is not just about the prayer of a regular day, but rather any common act that an individual should not do in the synagogue that would profane the Sabbath, such as talking on the phone and similar things, and it is obvious that this applies even more.
Only in a place where it is permitted to turn on even on Shabbat, such as when it is very hot or for the needs of the present public, then it is no less than Shabbat itself, when it is permitted to do so in their presence by a gentile and so on, and the same applies in the presence of a Jew who has not accepted Shabbat, for in this respect he is considered like a gentile.