The Tanya's twenty-sixth chapter opens with one of its most practical teachings: you cannot fight the evil inclination if you are depressed. Spiritual warfare requires joy.
Rabbi Schneur Zalman compares the inner battle to a wrestling match. If one of the wrestlers is sluggish and heavy-hearted, he will be thrown easily, even if he is physically stronger. The same applies to the war between the divine soul and the animal soul. Sadness—atzvut (עצבות)—makes a person dull, slow, and incapable of spiritual effort. It is the enemy's best weapon.
But the Tanya does not reject sadness entirely. It says that "in every sadness there is profit" (Proverbs 14:23)—but the profit is not the sadness itself. It is the joy that comes after. The right kind of anguish—genuine bitterness over one's distance from God—can break through the "iron wall" of the sitra achara and create an opening for the divine light. The Tanya cites (Psalms 51:19): "A broken and a contrite heart, God, You will not disdain." This breaking of the heart, done at the right time and in the right way, leads directly to the joy described in the preceding verse: "Restore to me the joy of Your deliverance."
This is why the Arizal—Rabbi Yitzchak Luria, the great 16th-century Kabbalist of Safed—placed the recitation of (Psalms 51) after the midnight Tikkun (spiritual repair) Chatzot prayer, before beginning Torah study. First, break the heart with genuine remorse. Then, study Torah with the joy that emerges from that brokenness. The light that comes from darkness is superior to light that has never known darkness.
The Tanya's practical advice: set aside specific times for examining your spiritual condition and feeling genuine anguish about your failures. But do not bring that anguish into prayer or Torah study. Those activities demand joy. Sadness has its appointed hour. Outside that hour, it is the enemy.
Truly this should be made known as a cardinal principle, that as with a victory over a physical obstacle, such as in the case of two individuals who are wrestling with each other, each striving to throw the other—if one is lazy and sluggish he will easily be defeated and thrown, even though he be stronger than the other, exactly so is it in the conquest of one’s evil nature; it is impossible to conquer it with laziness and heaviness, which originate in sadness and in a heart that is dulled like a stone, but rather with alacrity which derives from joy and from a heart that is free and cleansed from any trace of worry and sadness in the world. As for what is written, “In every sadness there is profit,”1 Proverbs 14:23. which means that some profit and advantage would be derived from it, the phrase, on the contrary, indicates that sadness in itself has no virtue, except that some profit is derived and experienced from it, namely, the true joy in the L–rd G–d which follows from genuine anguish over one’s sins at propitious moments with bitterness of soul and a broken heart. For thereby the spirit of impurity and of the sitra achara is broken, as also the iron wall that separates him from his Father in Heaven, as is commented in the Zohar on the verse, “A broken and a contrite heart, G–d, You will not disdain”;2 Psalms 51:19. then will be fulfilled in him the preceding verses: “Let me hear joy and gladness…. Restore to me the joy of Your deliverance, and uphold me with a spirit of magnanimity.”3 Ibid., vs. 10, 14. This is the simple reason why the Arizal4 See above, ch. 2, note 9. instituted the recital of this Psalm after the Midnight Prayer,5 Tikkun Chatzot. before commencing study, in order to study with the true joy in G–d which succeeds remorse. For such joy has an excellence similar to that of a light emerging from the very darkness, as is written in the Zohar on the verse, “And I saw that wisdom surpasses folly, as the light surpasses darkness.”6 Ecclesiastes 2:13. The emphasis is on the words מן החשך—literally “from the darkness.” Note there, and it will suffice for him who understands. Furthermore, Scripture states it explicitly: “Because you did not serve the L–rd your G–d with joyfulness…”7 Quoted in Shaloh, Asarah Maamarot, Maamar 3:4. See Igrot Kodesh by the Lubavitcher Rebbe, vol. 19, p. 351.—and everyone is familiar with the commentary of the Arizal on this verse.8 Deuteronomy 28:47. The following is sound counsel as to how to cleanse one’s heart of all sadness and of every trace of worry about mundane matters, even about children, health, and sustenance. Everyone is familiar with the statement of the Rabbis that “Just as one must recite a blessing for the good, [one must also recite a blessing for misfortune].”9 Mishnah, Berachot 9:5. In the Gemara it is explained that one should accept [misfortune] with joy, like the joy of a visible and obvious benefit, for “this is also for the good,” except that it is not apparent and visible to mortal eyes because it stems from the “hidden world” which is higher than the “revealed world,” the latter emanating from the letters vav and hey of the Name of Havaya, whereas the “hidden world” represents the letters yud and hey. Hence the meaning of the verse, “Fortunate is the man whom You chastise, O L–rd10 The Name of the L–rd is spelled here יה—yud-hey. Thus the “misfortunes” are blessings in disguise, originating in the “hidden” worlds..”11 Psalms 94:12. Therefore, the rabbis, of blessed memory, commented12 Yoma 23a. that it is to those who rejoice in their afflictions that the verse refers: “But they that love Him shall be as the sun going forth in its might.”13 Judges 5:31. For this is the joy of desiring the nearness of G–d more than anything in the life of this world, as is written, “For Your kindness is better than life…,”14 Psalms 63:4. and the nearness of G–d is infinitely stronger and more sublime in the “hidden world,” for “The concealment of His strength is there,”15 Habakkuk 3:4. and “The Most High abides in secrecy.”16 Psalms 91:1. Therefore, [the man who accepts affliction with joy] merits [to see] the “sun going forth in its might”—in the World to Come, i.e., the sun emerging from its sheath in which it is enclosed in this world.17 Cf. Nedarim 8b. But in the World to Come it will appear out of its covering, meaning that then the “hidden world” will be revealed and will shine and send forth light in a great and intense revelation to those who had taken refuge in Him in this world and had taken shelter under His “shadow”—the shadow of wisdom (chochmah), i.e., in the sense of “shade” as differing from light and revealed goodness. Suffice it for him who understands. As for the sadness which is connected with heavenly18 I.e., failure in matters of the spirit. matters, one must seek ways and means of freeing oneself from it, to say nothing of the time of Divine service, when one must serve G–d with gladness and a joyful heart. But even if he is a man of commerce and worldly affairs, should there enter into him any melancholy or anxiety about heavenly matters during the time of his business affairs, it is clearly a machination of evil impulse in order to lure him afterward into lusts, G–d forbid, as is known. For were it not so, whence would a genuine sadness, which is one that is derived from love or fear of G–d, come to him in the midst of his business affairs? Thus, whether the melancholy encroaches on him during Divine service, in study or prayer, or not during Divine service, he should tell himself that now is not the time for genuine anxiety, not even for worry over serious transgressions, G–d forbid. For, for this, one needs appointed times and a propitious occasion, with calmness of mind to reflect on the greatness of G–d, against Whom one has sinned, so that thereby one’s heart may truly be rent with sincere contrition. It is explained elsewhere when this time should be, and it is there explained also that as soon as his heart has been broken during these specific occasions, he should forthwith completely remove the sorrow from his heart and believe with a perfect faith that G–d has removed his sin in His abundant forgiveness. This is the true joy in G–d which comes after the remorse, as mentioned above.