This is true, but only to a certain degree. There is one thing that is in opposition to God that we must not shut ourselves out from, namely, lost sinners.
We must stay close to lost sinners.
Because we too were once lost sinners and God used those found sinners who stayed close to us to bring us to Himself. Yes, we must be discerning. Yes, we should seek to spend time with them in ways that honor God.
For example, if we have a friend that is into partying, getting drunk, etc...the best place to spend time with him is NOT at these drunken parties of his. OR If we have a friend who is into sitting at the coffee shop hoping to hook up with cute guys...the blest place to spend time with her is NOT at these coffee shops.
We must seek to lead them to Christ by offering alternatives. We must show them who we are in Christ and hanging out in those places for those reasons is not who we are in Christ.
All that to say, the purpose of being a Christian is knowing God and making Him known.
If you fail to do this, you've failed to carry out your calling.
In your ministering and your living you must be discerning lest you be led astray.