When you cannot say it to anyone else
Yaʿqūb ﷺ, told he was grieving too openly, answered this.
قَالَ إِنَّمَآ أَشْكُوا۟ بَثِّى وَحُزْنِىٓ إِلَى ٱللَّهِ وَأَعْلَمُ مِنَ ٱللَّهِ مَا لَا تَعْلَمُونَ
…innamā ashkū baththī wa ḥuznī ila-llāhi wa aʿlamu mina-llāhi mā lā taʿlamūn.
“He said, "I only complain of my suffering and my grief to Allāh, and I know from Allāh that which you do not know.”
Where this comes from
His sons told him he would destroy himself with grief. He did not deny the grief. He told them where he was taking it. The word he uses, bathth, means sorrow so heavy it cannot be kept in.
Source
The Qur'an · 12:86
Qur'an
- Qur'anic text in the Uthmani script via Quran.com; translation: Saheeh International