When a person’s imaan is strong, they will realise that everything Allah has decreed for them is good, even if they don’t understand the wisdom behind the Decree. So, when an affliction befalls them, they will know and realise that hidden in it is a great good and benefit for them. As Allah tells us:
“For it is possible that you hate something, yet Allah places in it a lot of good (for you).” (Surah al-Nisa:19)
“And it may be that you dislike a thing even though it is for your good, or that you like a thing even though it is for your evil. And Allah knows, whereas you do not know.” (Surah al-Baqarah:216)
When we realise that something disliked might cause or lead to something desired, this will ease for us the fact that our du’a does not seem to be answered, and sow in our heart the patience that is necessary to overcome the matter.
Know also that being tested causes us to increase our du’a, whereas having what we love causes us to be distracted from worshipping Allah. And with Allah lies the highest reward.