A Jew who has sinned, for example, by eating forbidden foods, committing adultery, or transgressing other biblical commandments, is still counted as part of the minyan. Despite the fact that he sinned, in his inner core he surely desires to be a part of the holy objectives of Am Yisrael. As the Chachamim say (Sanhedrin 44a), “A Jew, even one who has sinned, is still a Jew.” However, a person who sins in order to purposely incite God’s wrath does not count as part of a minyan, since he himself demonstrates that he does not belong to the Torah or to Israel (Mishnah Berurah 55:46-47).
According to some poskim, one who desecrates the Shabbat in public, even if he does it for his own pleasure, is considered an idol worshiper and does not count as part of the minyan (Mishnah Berurah 55:46). However, in recent generations, a few prominent poskim have taught that if a person who desecrates the Shabbat wants to be part of a minyan, we can include him. This is because today, the status of one who desecrates the Shabbat is different. In the past, when all of Israel observed the Shabbat, anyone who dared to publicly desecrate the Shabbat, even if he did it for his own pleasure, outwardly defied all of Israel and was therefore deemed as one who sins intentionally to arouse anger. However, in recent times, when unfortunately many Jews do not keep the Shabbat, its observance is not a measure of a Jew’s identification with his heritage, and therefore, if he himself wants to be part of the minyan, he may be counted. Still, it is not proper to appoint him as chazan.
.Melamed L’hoil, Orach Chaim 29 and Binyan Tziyon HaChadashot 23 rule to count a person who desecrates the Shabbat as part of a minyan. That is also how my teacher and rabbi, Rav Avraham Elkanah Shapira, ztz”l, ruled in practice. The foundation for their rationale is brought in Igrot Ra’ayah, part 1, 138, that the atmosphere of these generations entices people to sin almost against their will and therefore, sinners today are considered nearly annusim. Similarly, the Chazon Ish, Orach Chaim 87:14 and Yoreh De’ah 2:28, writes that most non-religious Jews have the status of tinok shenishbah (a child who was captured and raised among gentiles) and not mumar lehachis (a sinner who intentionally defies the Torah). Many other Acharonim have also dealt with this issue. There are those who are stringent, see Ishei Yisrael 15:16. Nevertheless, we have already learned that prayer in a minyan is a rabbinic ruling and the halachah goes according to those who are lenient.