I totally understand where you're coming from. To answer your questions fully, you need to break it down a bit. I myself am a 40 something engineer who has reached the peak of what I would like.

You basically have 3 categories of companies:

- Start ups - everything is loose and fast, the goal is to ship something before the company falls apart. Lots of coding, but high stress

- Mid size - there is old legacy loose and fast code but things are in some phase of stabilisation. There are lots of problems to solve and coding to do but usually less stressful and starting to see sensible engineering practices and decent culture

- FAANG - whole mix of stuff because these places are enormous. I've worked for Microsoft and enjoyed that. I worked for Amazon and hated that. The projects differ wildly and it's very competitive. The bonus is you get a paid a lot and there are smart people to learn from, but the con is the less nicer companies are good at forcing you to compete with your teammates and kicking people to the curb

In terms of "coding is the thing I like to do", this is a tricky one. As you get older the expectation is that you take on more responsibility. Your skills change from coding to helping other people code and coordinate work. For a company it is hard to justify paying someone with lots of experience to just do lots of coding - they can just find young enthusiastic people to do this. Your selling point is dispensing that experience and wisdom to level up your team.

I currently do way less coding at work than I would like which makes me sad, because of my seniority. However, I do enjoy helping other people do better and making things more efficient, which makes me happy. I compensate for lack of coding by having days booked out where I just focus on hands on stuff. I also do some private projects where I can build and do whatever I want.

If you just want to do what pleases you AND make money, your only real option is to start your own company. However the reality here is that you will likely invest a lot of time in non-engineering stuff (and learn a load more skills) just to make your company successful. If you just want happiness then find a private project to work on or contribute to. I have personally found happiness just going back to a midsize company that appreciated the injection of experience I gave and respected that I enjoy coding. They care more than most companies I've worked at. But remember that the relationship between you and your company is a mutually beneficial contract, everything runs on capitalism. You are free to screw over your company for a more lucrative contract just as they are to replace you (within reason), it is a free market.

You are essentially trying to fight against the natural transition of a less experienced junior dev to a more experienced senior one as you age and that's a difficult one to win. If you're above average then it's just common sense that most people you come across won't be as good as you :).

In summary:

- Happiness but not money - work for a company that appreciates you and does nice things. Charity organisations are likely to fit in here but there are companies that don't have sociapaths as managers believe it or not :). The nice ones are more likely to be non-US ones

- Medium happiness and medium money - midsize company that still tries to keep its employees happy. Good ones will have flexible work polices like remote work, etc.

- Unpredictable happiness and high money - FAANG (experience is very dependent on project and team, Microsoft is a good one depending on your global location)

- Unpredictable happiness and unpredictable money - run your own company :)