According to Chassidic principles, we may instruct a person to commit a minor sin to prevent others from committing a major sin, even if you are involved. Whether you should pray in a synagogue where you’re unsure of the religious observance of those leading services depends on the specific issues at hand. It may be effective to visit occasionally.
https://www.torahrecordings.com/rebbe/igroskodesh/011/010/3644