Aaron of Karlin (1736-1772) belonged to one of the early generations of ḥasidic rabbis and was instrumental in bringing Ḥasidism to what is now Belarus. A new translation of one of his homilies by Ariel Evan Mayse and Daniel Reiser dwells on the distinction between what he terms “depression” and “melancholia”:
Depression is obviously not a sin, but the dullness of heart (timtum halev) brought about by depression cannot be caused by even the most vulgar of sins. . . .
Depression is the depths of hell, may heaven save us! And what is the essential nature of depression? It means [thinking] about what you deserve and what you are lacking, whether in physical or in spiritual matters. But this is just self-obsession! What does it matter what we are missing—as long as heaven [i.e., God] isn’t lacking. . . .
Melancholia, [by contrast], means being brokenhearted, [understanding] that one has not yet begun [the work of spiritual and moral self-improvement].
Read more on In geveb: https://ingeveb.org/texts-and-translations/mikvah-and-mitzvah-melancholia-and-the-spiritual-life