A number of considerations:
If certain people cause us to sin easily, being in their presence could be an occasion of sin, and that knowing something is an avoidable occasion of sin but choose to enter it anyway, that itself is a sin. So, if it is not uncharitable or irresponsible, we probably should avoid certain company that we know would lead us to sin.
On the other hand, there are many people that we cannot avoid, whose behaviours are manifestly sinful. Jesus did not call us to avoid people, but to be light of the world and salt of the earth. If no one brings the Good News to the unbelievers, who would repent? If no Christians associate with the sinners, who would come to know God’s mercy and transforming grace? Jesus called us to follow Him, but He, likewise, sent us to preach the Good News.
So what do we do? Do exactly as Jesus commanded. We must go to Him first every day and asked for the grace to remain close to Him. We must ask to receive His blessings to be His presence of love and mercy in the world. Then go and be Christ to others: to bless, to forgive, to gently love, and boldly testify God’s goodness. Those who have eyes to see and ears to hear will be touched. And for those who do not, we must be like Jesus and pray and fast for their salvation, and entrust them to God.