But if you are unable to eliminate those innovations and objectionable practices from the mosque, then you must look for another mosque that is free of innovation and perform your prayers there.
Funeral prayer for one who died in disbelief
Question: Is it permissible to perform the funeral prayer for a deceased person whom we know believed that the saintly dead can benefit or harm, who used to call upon them for help, and whose actions are, in Islamic law, outright polytheism? May the funeral prayer be offered for someone who died in that condition, or for a person who prayed only on public occasions such as the two ‘Eids and the like?
Answer: Anyone who dies in the state you have described—seeking aid from the dead, believing they can benefit or harm, or who deliberately abandoned the prescribed prayer and died persisting in that state—is a disbeliever, Allah forbid. No funeral prayer is to be performed for him, nor is he to be buried in the Muslims’ graveyards. Allah says about the hypocrites: “And never pray over any of them who dies, nor stand at his grave; indeed, they disbelieved in Allah and His Messenger and died while they were defiantly disobedient” (Qur’an 9:84). Whoever dies upon disbelief in Allah and associating partners with Him is neither to be prayed over, washed, nor buried in the believers’ cemeteries.
If you are certain that he died in that state without repenting, then do not perform the funeral prayer for him—whether because he persisted in the major shirk you mentioned, or because he obstinately abandoned the prayer until death. In either case, as we have explained, no funeral prayer is to be offered for him, Allah forbid, for he died upon disbelief and polytheism.