Our hearts do not know everything. What he knows about us is that in Christ we have beauty we can't yet see. So the answer to the problem of a condemning heart is the gospel, the power of God, his word spoken into our experience. Now, John does not here teach about the sanctification process. The answer to condemnation is clear, but it is not easy.
Christians spend all their lives trying to learn to put off the old man and put on the new.
We are subject to the wiles of the devil and the influence of the sinful nature. Learning to hear God, who is greater than our hearts, so that we believe him is a long, profound, and difficult process. But it's the only one that works. A mature Christian That is why in the next paragraph John describes what a mature Christian looks like. He doesn't dwell at length on the process of growing up, but simply tells us what a person looks like whose heart does not condemn them.