There are two reasons a person might cry. One is because he is in pain and there is nothing left to do but cry. The other is something holds him back from attaining his desire, so he cries, the tears rip away that deterrent, and he reaches his goal.

The first is a cry of hopelessness. The second is a cry of joy: one comes close to the light, cries out to reach it, and all the ugly baggage of the past falls away.

הבכיה היא רעה מאד, שהאדם צריך לעבוד את ה׳ דוקא בשמחה. רק אם הבכיה היא מחמת שמחה ודביקות השי״ת אז טובה היא מאד

Crying is very bad; one must serve G‑d with joy.

The only exception is when you cry from joy and bonding with G‑d.

Then it is very good.

—Tzava’at Harivash 45