Matthew 7:21-23 reads” Not every one that saith unto me, Lord, Lord, shall enter into the kingdom of heaven; but he that doeth the will of my Father which is in heaven. Many will say to me in that day, Lord, Lord, have we not prophesied in thy name? and in thy name have cast out devils? and in thy name done many wonderful works? And then will I profess unto them, I never knew you: depart from me, ye that work iniquity.” Does this scenario take place at the great white throne judgement?
We know Matt. 7:21-23 can’t be about the church because when the time comes the Lord will simply take us and leave non-believers alone. There won’t be any discussion about who belongs to Him and who doesn’t.
Personally, I think it’s about Tribulation survivors. They will all appear before the Lord at the various judgments described in the Olivet Discourse parables (Matt. 24:43-25:46) just after the 2nd Coming. At that time many will try to talk their way into the Kingdom. Some will even claim to have performed miracles in His name, but He will expose the hidden motives of their heart and send them away, saying He never knew them.