Abu Hurairah (May Allah be pleased with him) reported:
The Messenger of Allah (ﷺ), "The supplication of every one of you will be granted if he does not get impatient and say (for example): 'I supplicated my Rubb but my prayer has not been granted'."[Al-Bukhari and Muslim].The narration of Muslim is: "The supplication of a slave continues to be granted as long as he does not supplicate for a sinful thing or for something that would cut off the ties of kinship and he does not grow impatient." It was said: "O Messenger of Allah! What does growing impatient mean?" He (ﷺ) said, "It is one's saying: 'I supplicated again and again but I do not think that my prayer will be answered.' Then he becomes frustrated (in such circumstances) and gives up supplication altogether."
App reference: Book 17, Hadith 35
Arabic/English book reference: Book 17, Hadith 1499