Yoga Sutra is the key to happiness.

Vrittayah pancatayah klishta aklishta”, meaning that there are five categories in which our thoughts take form and of these forms, some of them are neutral and others are painful.- Yoga Sutra 1.5

Pramana viparyaya vikalpa nidra smritayah”, they are: true perception, incorrect knowing, imagination, sleep, and memory, so every thought form can be categorized into an one of these.- Yoga Sutra 1.6

In 1.5 and 1.6 of the Yoga Sutra, by Patanjali, there are five functions of the mind each has the power to either cause us pain or not. So, true perception is to see or visualise clearly and infer through a reliable source or directly by you. Viparyaya is wrong knowledge which means incorrect perception of something and yet assuming it to be right. Vikalpa refers to the imagination, the ideas in our thoughts. Nidra is when the body and mind are in a state of deep sleep where the mind is at a very subtile level. Last of all, Smritayah is memory, the remembrance of our past.

It is necessary to understand how our minds function for two basic reasons. Firstly, by being able to identify the particular function that the mind is working on helps you to differentiate between genuine thoughts and thoughts of misperception. By doing so, you will avoid pointless suffering. Secondly, these two Yoga Sutras remind us that the main aim of yoga is to eventually work with the mind. The mind has its fluctuations and predefined temperaments but, the essence here is to understand that the Self is distinct from the mind and knowing this will eventually remedy you of your undesired suffering.

The functions of mind, as described by Patanjali are neither good nor bad but to be neutral. Each has the potential to cause suffering or not. The right perception might be quite painful and upsetting. Whereas incorrect perception may make you happy and feel good, just like the saying, “Ignorance is bliss.”

The other functions are in the same way, likely agents of pain or not. For instance, Hypochondria is an example of the mind causing agitation unnecessarily and on the other hand, we see that innovation, positive attitude and creativity are always of great value.
Deep sleep relaxes you, while a night of erratic, disturbed sleep (or simply lack of it) can have a negative impact your disposition and ability to focus the following day.

The most evident thing being that, memories can bring you happiness or cause you distress. But, on a much profounder level, a memory can affect your present state more than you may realize. Memories of bad experiences could keep you from living your life to the fullest.
Remember always that your mind and the Self are two different entities. Even though you may perceive the right thing but that is not enough to reduce your suffering, so what Patanjali teaches is that it is not enough to just have the right perception of things but also to discern between the Self and your mind, so that you can act from the Self. Once you start practicing that you can see the unkindest truths without being shattered by them.

Knowing how your mind works is the first step to build a foundation so that you can see your Self isolated from the way your mind works, and eventually, being steadfast. Over time, practicing this can help you bring down your distress by first helping you to see clearly if at all you have something to be troubled about! Practice it daily, just correcting yourself can be a significant step in learning to separate the mind and all of its changeability from your true Self.