When the complaint is aimed upward
God invites the honest word, including the one that comes out hot. The Qur'an keeps the sentences its prophets said at their worst moments, and it keeps them without softening the wording. Ya'qub, decades into losing a son, says "I bring my anguish and my sorrow to God alone", and the address is the thing to notice: whatever he was carrying, he carried it toward God.
Anger at God usually arrives with a second fear attached, that the feeling has already cost you your standing. Scripture is calmer about this than we are. Yunus "went off in anger and thought we would not constrain him", and his story does not end there; it ends with him calling out from inside the dark and being answered. The change came in where he aimed his words. He was the same man in the same distress when he finally aimed them at God.
The Qur'an also records what people think when the ground gives way. At the trench, with the city surrounded, the believers are described as "entertaining all kinds of thoughts about God". Maryam, in labour and alone, says "If only I had died before this". Those words were kept in revelation, which tells you how much room a person in extremity has to speak plainly.
The complaint is also heard as speech. A woman came to the Prophet about her husband, and sura 58 opens by reporting that she "brings her complaint to God", with God confirming he heard the whole exchange. Elsewhere the Qur'an says God has no love for evil speech aired in public, "except by one who has been wronged". The one carrying an injury is heard on different terms.
None of this explains why the thing happened. The verses below do something narrower and more useful: they show where to put the anger while the answer is missing, which is to say it to God and to keep saying it. Musa and Harun are told "I hear and I see" before their situation improves at all, and Ya'qub is told "do not despair of God's mercy" while Yusuf is still gone. If you are in the middle of this, unanswered dua and grief sit close by.