The Prophet ﷺ said, "Dreams are of three kinds. There is glad tidings from Allah, there is what the mind tells itself, and there is something frightening from Satan. So if any of you sees a dream that pleases him, let him tell it if he wishes, but if he sees something he dislikes, let him not tell it to anyone, and let him get up and pray."
حدثنا هوذة بن خليفة حدثنا عوف عن محمد
عن النبي ﷺ قال الرؤيا ثلاثة فبشرى من الله وحديث النفس وتخويف من الشيطان فإذا رأى أحدكم رؤيا تعجبه فليقصها إن شاء وإذا رأى شيئا يكرهه فلا يقصه على أحد وليقم فليصل
Its isnad is sahih, and it has preceded in similar wording. It is found in Abu Dawud 4/304, no. 5019, in the book of manners, chapter on what has been said about dreams, and Tirmidhi 4/532, no. 2270, in the book of dreams, chapter on the statement that a believer's dream is one part of forty-six. Something similar is found in Bukhari 9/48, in the book of dream interpretation, chapter on shackles in a dream, and Muslim 4/1773, no. 2263, at the beginning of the book of dreams, and Ibn Majah 2/1285, no. 3906, and Darimi 2/168.