Because sins are offenses or debts that need to be repaid, confession is what forgives these debts. Therefore after confession we have been forgiven our debts. Because we have been forgiven our offenses, therefore we are worthy to be in the presence of God, which on Earth is the Eucharist.

The situation is that simple in Latin theology (at least in the official version, not excluding that there may be many people who think themselves "worthy" of receiving Communion.) Witness for instance the prayer "Lord I am not worthy..." before the reception of Communion.

Besides that, the prayer of St. Ambrose before Mass is printed in the 1962 Missal as a preparation for Mass (optional). It reads in part (my emphasis):

"May your body and blood, which I intend to receive, although I am unworthy, be for me the remission of my sins, the washing away of my guilt, the end of my evil thoughts, and the rebirth of my better instincts. May it incite me to do the works pleasing to you and profitable to my health in body and soul, and be a firm defense against the wiles of my enemies."