This is a theme that Rav Tzadok (channeling his teacher the Izhbitzer) returns to on a number of occasions.
For a brief statement of his thesis, see Tzidkat HaTzaddik 40:
עיקר התשובה הוא עד שיאיר ה' עיניו שיהיו זדונות כזכיות ר"ל שיכיר ויבין שכל מה שחטא הי' ג"כ ברצון הש"י
... ומאחר שהש"י רצה כן הרי הכל זכיות וזוכה לכפרה גמורה
The main idea of teshuvah is to reach the point where Hashem helps him to understand that all of his sins were also performed in accordance with Hashem's Will ... and since Hashem wanted it to be so, everything is actually meritorious, and he merits complete atonement.
and similarly in Tzidkat HaTzaddik 100.
For a somewhat longer treatment, see Peri Tzaddik, LeRosh Chodesh Menachem Av 1.