The prayer is not valid behind an openly sinful person, just as it is not valid behind an unbeliever, …
His statement, “Nor is it valid behind an openly sinful person.”
The author, may Allah have mercy on him, has explained those whose leadership in prayer is invalid, either without qualification or when compared with someone more complete than they are.
Linguistically, a fāsiq (openly sinful person) is one who departs or goes out. It is derived from the expression, “The fruit has burst out of its peel,” meaning that it has emerged.
Technically, it is one who departs from obedience to Allah by committing a major sin short of disbelief, or by persisting in a minor sin.
The term fāsiq may also be applied to an unbeliever, as in Allah’s saying: “So judge between us and the defiantly disobedient people” [al-Ma'idah: 25]; and in His saying: “Except Iblis: he was one of the jinn, and he rebelled against the command of his Lord” [al-Kahf: 50]; and in His saying: “But as for those who defiantly disobeyed, their refuge will be the Fire” [al-Sajdah: 20].
His statement, “behind an openly sinful person”: the apparent meaning of his words, may Allah have mercy on him, is that the prayer is invalid behind an openly sinful person, whether the follower is like him or otherwise, because he stated this without qualification. Thus, if two people who backbite others come together and the time for prayer arrives, neither may lead the other in prayer. If Zayd leads Amr, the prayer is invalid; and if Amr leads Zayd, it is invalid. Therefore, they should pray individually. Likewise, if two people who both smoke come together, neither may lead the other, since each of them is openly sinful. And if two people who have shaved their beards come together, neither may lead the other, because both are openly sinful. An openly sinful person cannot serve as an imam. If this view were applied, many people would miss praying in congregation.
The second view is that prayer is valid behind an openly sinful person, even if his sinfulness is outwardly apparent. This is supported by two kinds of evidence: textual and rational: