Hello John.
I was reading your post and I must admit I was rather surprised at what you wrote.
This seems to be a contradiction.
Another contradiction John, either salvation is free or it is not, either one or the other.
What claim were these folk making to the Lord?
Why did the Lord not know them?
Saying the name of Jesus does not mean salvation of course, believing in the Gospel of Jesus Christ most certainly does mean salvation.
One not only confesses Jesus but also believes in Jesus from the heart!
Romans 10:10
for with the heart a person believes, resulting in righteousness, and with the mouth he confesses, resulting in salvation.
John posted vital "IFs" Jesus made quite clear. Our salvation requires a continual belief, not merely an initial belief as Jesus laid out. I've known many people who have first ruined their lives though abuses,
then come to a conclusion they no longer believe anything about God, becoming outright atheists hating anything to do with God. Those are not mere emotional fits, but lasting changes of mind. Some had gained much knowledge of the gospel, but most not growing at all beyond their initial encounter with the call of the Father to answer to Jesus.
Some say those people were never really saved. How would anyone know that, even that person that doesn't realize the gravity of their decisions until judged by God, those who say and do in Jesus' name but not born again?
Long ago I ministered with some licensed and even an ordained preacher who, like myself, discovered we were calling upon a Lord we didn't know, like the sons of Sceva (Acts 19:14) who were obviously driven by zeal.
The vital thing is to come to that realization before hearing "Depart from me for I never knew you." Once getting that right while still living here, it's equally vital to let your little branch be productive, not subject to being determined worthless and cast into the heap to be burned.
James covered that, explaining the link between faith and works of righteousness, faith earning salvation, works verifying. It's a little like what President Reagan meant by his "Trust but verify" statement concerning the nuclear arms agreement with Russia. It was extremely necessary to trust each other to keep the treaty, but trust alone would not be satisfactory. Knowing some people will be found (too late to help them) ministering in Jesus' name, however earnestly, but not born again or believing as they should, God is not about to take them in, but those branches will be destroyed. He knows within their lifetimes they miss the mark in significant ways, so has basis for judging and condemning them.
Most people I know claim they believe in Jesus, but few go beyond that simple statement, living their lives out in ignorance of what they supposedly believe. "I'm OK, I don't need to be preached at". I believe many of them are in danger of being found to be sterile branches that never produce the fruit God expects, withered branches taking up space on the Vine (Jesus) for a season. The Vine itself doesn't prune those. The Husbandman does that. He won't find branches that happened upon the Vine without being grafted in. The wild branches are on other vines that never produce good fruit, none living in the vineyard, but are found in the wilderness. There is no need to prune those, though branches of promise may be grafted onto the true Vine. A husbandman (vineyard keeper) will give a branch a try through grafting, but if it doesn't take and produce, it is pruned off and burned, not returned to the wilderness. All pruned materials that fail for whatever reasons are burned to prevent spread of disease and pests onto healthy branches. The analogy of a vineyard is a favorite of Jesus and apostles, the perfect natural scenario.