I had a problem with a job boss who would/could not change and my T pointed out I could stay at the job and get depressed or I could leave. I retreated back into what I wanted to accomplish for and in myself, regardless of the boss, and came up with a few things I could still work on in that situation, but made sure I paid attention to how I was feeling so I would not fall into still trying to bang my head against his brick wall
Fortunately, my situation changed within the year and my skill (and big mouth :-) made it so they did not need me full-time and then the boss found another job, I terminated therapy (and did not need the job at all; I was using it primarily to pay for therapy) and I moved and retired, etc.
I had more going for me with the job than just that boss's problems. If I were you I'd make a two-column chart of pros and cos of what you get from the job versus what causes you difficulties and make yourself your own one to five-year plan and concentrate on that instead of the idiot boss? It can be so easy to get tunnel vision and only look at situations that suck the life out of us and not remember the stuff we like that puts energy and life back into us.