This is always a can of worms. You will get a lot of different opinions. Here are some other translations, maybe it will help.
Matthew 7:23
(NLT) But I will reply, 'I never knew you. Get away from Me, you who break God's laws.'
(NIV) Then I will tell them plainly, 'I never knew you. Away from me, you evildoers!'
(NIrV) Then I will tell them clearly, 'I never knew you. Get away from me, you who do evil!'
(NASB) "And then I will declare to them, 'I never knew you; DEPART FROM ME, YOU WHO PRACTICE LAWLESSNESS.'
(NAS77) "And then I will declare to them, 'I never knew you; DEPART FROM ME, YOU WHO PRACTICE LAWLESSNESS.'
(MSG) And do you know what I am going to say? 'You missed the boat. All you did was use me to make yourselves important. You don't impress me one bit. You're out of here.'
(MKJV) And then I will say to them I never knew you! Depart from Me, those working lawlessness!
(KJV) And then will I profess unto them, I never knew you: depart from me, ye that work iniquity.
(HCSB) Then I will announce to them, 'I never knew you! Depart from Me, you lawbreakers!'
(GW) Then I will tell them publicly, 'I've never known you. Get away from me, you evil people.'
(GNB) Then I will say to them, 'I never knew you. Get away from me, you wicked people!'
(ESV) And then will I declare to them, ‘I never knew you; depart from me, you workers of lawlessness.’
(ASV) And then will I profess unto them, I never knew you: depart from me, ye that work iniquity.
(AMPC) And then I will say to them openly (publicly), I never knew you; depart from Me, you who act wickedly [disregarding My commands]. [Psa 6:8]
ἀνομία
anomia; from G459; lawlessness: — lawless deed (1), lawless deeds (2), lawlessness (12).
My take take on this verse is the word "practice". We all sin sometimes, but there are those who "practice" sinning.
The word "law" means several different things to people. To some it means any part of the law. To others it means only the penalty of the law.
To yet others it only means the ceremonial part of the law. Often it's a combination of all the above.
1 Tim 1:9; realizing the fact that law is not made for a righteous person, but for those who are lawless and rebellious, for the ungodly and sinners, for the unholy and profane, for those who kill their fathers or mothers, for murderers
Not everyone who thinks they are "righteous" really is.