St. Paul taught about a man living in a Christian community while living an immoral life:
I wrote you in my letter not to associate with immoral people, not at all referring to the immoral of this world or the greedy and robbers or idolaters; for you would then have to leave the world. But I now write to you not to associate with anyone named a brother, if he is immoral, greedy, an idolater, a slanderer, a drunkard, or a robber, not even to eat with such a person. For why should I be judging outsiders? Is it not your business to judge those within? God will judge those outside. “Purge the evil person from your midst.” 1 Cor. 5:7-13
My brothers, if anyone among you should stray from the truth and someone bring him back, he should know that whoever brings back a sinner from the error of his way will save his soul from death and will cover a multitude of sins. James 5:19-20
As you imply, the idea is to judge the behavior and to conduct yourself in such a way as to turn them towards amendment of what they’ve been doing. If they amend and repent, then it is in the past–the brother who repents and is willing to amend himself is to be forgiven, even if it is over and over. (Which is, by the way, not the same as coming back and expecting to be put into a position of trust that is not deserved because one has chosen to squander the willingness of others to trust. To forgive is not the same as to be a doormat for those are not trustworthy.)
The main thing is that the Lord thirsts for each soul. If we are straying, let us hope we’ll have someone willing to try to induce us to amend ourselves! We do not want to be left alone in our sin, either because no one is willing to correct us or because no one is willing to engage with us enough to bring us around. The best course for us is the middle one, where the sin is called to task but the sinner is called back to life. That is only what we want for ourselves, and putting ourselves in the place of the person who is straying is a good way to decide how to proceed.