One: Hefsek for those that are outside the minyan. If you're passing by and you hear a minyan, you can say devarim shebikdusha along with them, such as kaddish and kedusha. Also, if you hear someone make a bracha, of course you can answer amein even if you're not in the same room. BUT, if an Avoda Zara is mafsik between you and the minyan, then you cannot say devarim shebikdusha. And, many poskim say that you can't even answer amein to brachos you hear.
And It gets worse. Like it or not, many poskim say that the rule that a davar tamei is mafsik also applies to a person who is Oveid Kochavim.
Initially, this offended my American-raised sense of respect for different creeds, and I could not believe that it makes sense to call an Akum a Toeiva. Indeed, plenty of poskim (see Be'er Heitev there, ר''ל שלא יהא ע''א מפסקת אבל עובד ע''א אינו מפסיק מ''א וכ''כ דבר שמואל סי' קפ''ט, the Aruch HaShulchan, and the מנחת אלעזר) do hold like that. But the Mishna Berura and Elyah Rabba and Pri Megadim take it at face value. It says Akum, it means Akum, and even an Oveid Avoda Zara is mafsik. I later realized that Akum means "A person that consciously rejects the Yichud Hashem," a person that rebels against the Ribono shel Olam. If his Idol is a to'eiva, kal vachomer he is. The idol is just an innocent domeim that a man used to give physical expression to his debased thoughts.
Two: Interfering with a minyan when it is in the same room. If there is an Avoda Zara in the room itself, many poskim hold that the Avoda Zara will divide the mispallelim, meaning that if you have five on the left, five on the right, and AZ in middle, you do not have a minyan.
And even if there are ten on the right, and you are on the left, with an Avoda Zara between, you can not even answer amein on their brachos, and certainly not devarim shebidkusha.
And there are even some that say that even if you have ten together without any hefsek, you simply can not make a minyan to say devarim shebidkusha in a room that has Avoda Zara in it, no matter where the AZ is located within the room. It's me'akeiv on the Hashra'as HaShechina in the entire room.
And, finally, as above, that this problem might arise with any individual that is an Oveid Avoda Zara who is present during davening.
Section Lechatchilla: Choose a place that has no Avodah Zara.
The Tanchuma is in the beginning of Bo, 5
Similarly, the Yaklut Shimoni (קפז).
But the source, the Trumas Hadeshen, makes it clear.
Mishna Berura there sk 29
in sk 30 he explains what the Rema means and corrects a a ta'us sofer
Thus, the Trumas Hadeshen applies this Medrash le'halacha - that lechatchila, one should daven where there are no idols. However, if that is not an option - or, most importantly, if avoiding the idols would result in a davening with distractions or interruptions - then you should daven where there are idols.
This shaila comes up often, especially for people hospitalized in a Christian institution, which often have crosses or crucifixes on the wall, and it is brought in our contemporary sefarim. Answer: Yes, you can daven there. Just don't bow down towards the crucifix.
Shearim Mitzuyanim B’halacha 18-6
If we're applying this Medrash le'halacha l'maiseh, we have to answer the famous question of why davka now did Moshe say he had to leave the city to daven. Why wasn't this true in the other cases? The answers to this question might inform the application of this kpeida.
The Netziv in Va'eira says that this only applies when he had to be outdoors, when he had to spread his hands towards the sky. If he was davening in a place that is kavu'a for tefilla, the fact that there are getchkehs in the city is irrelevant. Maybe, according to the Netziv, the same would be true if you're davenning in one room in a building that has idols in another room. (I don't know why he says that he would daven in a shul. The same hetter ought to apply if he davens in any clean house.)
The Chasam Sofer says that in the other cases, he davened in the city because if he went outdoors he would get interrupted by passers by; as we saw, the preference to daven away from the Avoda Zara is only if it does not come at the cost of interruption and distraction. But during Barad there was nobody on the streets, so the preferred place to daven was outside the city.
Here ends our discussion of the lechatchila, teaching us that if one is able to choose, then one should daven as far as possible away from idols, whether they're in the room, or the building, or the city. Unless you live in Bnei Brak or The Town of Palm Tree, we are very, very, far from this Lechatchila. As far as lechatchila goes, the Rambam holds that lechatchila it's assur to even walk in to a city that has Avoda Zara in it:
Rambam 9 AZ 9
Section Bedieved: Two cases where this issue is me'akeiv even bedieved.
Lomdus: It is important to keep in mind the reason why these cases are even bedieved while the first application was only lechatchila. In the first case, you don't need any bigger makom than the place that you're standing, so if there's Tumah outside of your body, it's not me'akeiv. In the following cases, we need a tziruf; either tziruf TO a makom, a connection to a place where there is the kedusha of a minyan, or tziruf WITHIN a makom, that the individuals within a room join to create a din of a makom kedusha. In these cases, Tumah is me'akeiv the tziruf - the connection to the makom kadosh or the chalos of a makom kadosh.
OC 55:20, you can answer devarim shebikdusha if you're walking by a shul. Or if you are far away and you have a phone connection (it goes without saying that some disagree about the phone. Let's ignore them for the purposes of this discussion.)
The Beis Yosef and the Mechaber say Akum. On that basis, the Pri Megadim and Elya Rabba and Mishna Berura say it means any idolater.
The Magen Avraham, the Aruch Hashulchan, and the Be'er Heiteiv hold it only refers to idols, not idolaters. Because the Mishna Berura is machmir, I am, for purposes of this discussion, working with the machmirim, that an oveid AZ is also mafsik.
The Mechaber used the expression ויש אומרים that XYZ is mafsik. The Mishna Berura says that it's not black and white, that the Mechaber is not being machria.
So: According to the Mishna Berura and the Chayei Adam, it is a Yeish omrim, but he leans towards being machmir, and he applies to even to an Akum. And according to them, you would be allowed to answer kaddish and kedusha with the siyum hashas, but not Barchu. (I don't know why they say that Yehei Shmei is "pesukim." Kedusha is, Yehei Shmei is not.)
As I said earlier, it gets worse. Not only can you not answer a davar shebikdusha that requires a minyan, the Mishna Berura (55:sk63) says you can't even answer a simple amein to someone's bracha where there's a hefsek davar tamei between the mevareich and the oneh amein.
בתוך ד"א. משמע דאם שום אדם אינו יושב בתוך ד"א של הצואה מותר להתפלל אף על פי שהצואה מפסקת ביניהם ובין הש"ץ יכולים להחזיר פניהם מיהו בסי' נ"ה ס"ך י"א דלא יענה אמן כשיש צואה מפסקת ביניהם:
but le'maiseh he is machmir in 55.
Two: Interfering with the chalos Kedusha of a minyan when the Davar Tamei is in the same room as the minyan.
The Ben Ish Chai says clearly that having an Akum in the room is not a problem
תשובה: כתב השו"ע (סימן נה סק"כ) שהשומע קדיש וקדושה אפילו מי שאינו נמצא עמהם ושומע יכול לענות,
End note: Something clever from Reb Yakov Kopel Chosid, a talmid of the Baal Shem Tov, that uses our Tanchuma. Even my father zatzal would have liked it.
He works with the idea is that the Shechina does not appear when there are idols around. Lavan was a very clever man, and he used this din as evidence that Yaakov had stolen his Traphim. The night after Yaakov ran away, Lavan had gilui Shechina in a dream, and it became obvious that Yaakov did not! That proved both elements - that the idols were no longer by Lavan, and that the idols were by Yaakov. Of course, Lavan was not nispaeil from the fact that the Ribono shel Olam appeared to him in his dream, and warned him not to bother Yaakov. He still wanted to get his precious idols back!