About 9 months into my job, the company was hit with two lawsuits, and the leaders became very secretive and elusive and started changing rules to save money of questionable legality. For example, a rule was added to state that we had to work 40 billable hours a week.
This doesn't sound that bad, but because of the lawsuits and attempts to settle them, any work done for the plaintiffs in the aforementioned lawsuits was not counted as "billable", and most of that work would eat up multiple hours of my day. This meant that in addition to the eight hours I had to work on a billable client, I would also end up spending an extra three to four hours working on non-billable stuff. This went on for multiple months, I started feeling depressed, but I put up with it because I really liked the company.
Eventually, the company laid off 2/3 of the staff without any notice to any of the workers. I went from "employed" to "unemployed" overnight, and when I managed to get in touch with the CTO, he basically told me "thems the breaks. Sorry". I felt pretty betrayed, because I had spent two months working 60 hour weeks, all to be laid off because I was working on the wrong projects.
After that, I made a bit of a vow to myself to remember that a job is, at its core, a business transaction. You sell your time and expertise for compensation. It's great if you really like your boss and your coworkers, that'll help avoid depression, but remember at the end of the day, a company is not your family, and if they don't think you're creating enough value for them, they will end this transaction.