"You should accept as grace all those things which deter you from loving the Lord God." (Francis of Assisi, Letter to a Minister)
That's a hard teaching. At first it might seem to make no sense.
So why should we thank God for whatever impedes us from loving Him? Because this is the surest path to humility, to confessing before God that we do not yet love him as we ought.
This humility is the way to the holiness of life in which nothing will deter us from the love of God; not our joys and the goodness around us, because all of it will speak of God without any danger of distraction, and not our sufferings and rejections, because even these we will gratefully receive as sharings in the sufferings of Christ of which we have been found worthy, in communion with Christ crucified in the salvation he is for the world.