An example would be a Catholic voting for a pro choice politician's thus ignoring what Church’s teaching of pro life
“The answer is yes when they are following the teachings of the Church”
The question doesn’t ask about “following the teachings” or “indwelling of the Holy Spirit”. It is a question of epistomology; how do we know. Before the individual follows the teachings of the church, does the Holy Spirit lead the individual to believe the teachings of the church are true?
The question does not deal with all of the teachings of the church, just enough to convince the individual to commit to the church for salvation. Is that the leading of the Holy Spirit in the life of the individual?