Perhaps one solution is to divorce your own self worth from the quality of the software you happen to write and to realize that you are an employee first and a software engineer second - make decisions that increase the amount of money the company makes and look for self worth in that itself or in hobbies/family/friends/something else.
That’s was the main reason that I do my pet projects: to detach myself from some corporate persona that is a completely different from my professional self.
I still have a lot of professional pride, but it comes more from my personal projects and sharpening my craft than to some corporate version that could be dragged down by structural issues.