That was Old Covenant before Jesus died and rose from the dead which triggered the New Covenant. Jesus was talking to the Jews who thought they could be saved by keeping the law. Much of the beatitudes were meant to flummox the Pharisees to show NO ONE can keep the law and ALL need Jesus.
As prophesied in Joel 2:32, today's' new covenant declares, "Whosoever shall call upon the name of the Lord shall be saved" Rom 10:13.
And neither you nor I know for sure who those people are. That's why Romans 2 and elsewhere shows the folly of judging others and to not judge another. They can be as bad as Bad Bob the Albino, but if they've received Jesus they are saved. It's all God's grace.
I’m sure you’ve read Matthew 25:31ff. As you recall, it’s a vivid depiction of the Day of Judgment. The ‘sheep,’ were the ones who had cared for the hungry, thirsty, naked, imprisoned, sick, etc. The ‘goats,’ had ignored the needs of those around them.