Jesus is referring to those who let their riches into their hearts,
From the bible - “And when they had heard this, the disciples wondered very much, saying: Who then can be saved?”
From the Haydock commentary - “They wondered very much. The apostles wondered how any person could be saved, not because all were rich, but because the poor were also included, who had their hearts and affections fixed on riches. S. Aug. and Nicholas de Lyra.”
we are supposed to put God first in our lives, and love Him above all else, and that is why it is wrong to let anything take the place of God in our hearts.
and unless i’m wrong, i think the “riches” He is referring to is not just money, but instead whatever we treasure above God.
“Jesus saith to him: If thou wilt be perfect, go sell what thou hast, and give to the poor, and thou shalt have treasure in heaven: and come follow me.”
although this is more referring to the call to religious life, it is also telling us, detach from your worldly attachments, and follow Christ, and by casting away your worldly treasures, you will obtain far greater treasures in heaven,
heaven may also be referring to God inside of you, so while you empty yourself of useless treasures, you are filled with the greatest treasure of all, God.
alright, hope this helps, take care.