I think you should keep enough cash that you feel comfortable with and helps you stick to your investment plans without wavering.
There's a prevailing belief that one needs not a lot of cash and should constantly buy buy and buy.
Of course things creep up that can raise expenses or set one into panic mode. Losing job in a recession like one we had recently is an example. In some cases, people had to retrain themselves or learn new skill sets. All those things take up more money than what we recommend as 6 months savings. Some people also do dollar cost averaging or are timing the market. Maybe they'll invest some of their money and the other half is for buying on small or big dips. To me, cash is kinda like ammunition and if you want to win or get good bargains which is a moving target, you need a lot of ammo, the more the better.
40K does seem like a lot to me though, you can definitely trim that down to 30K and maybe more. Whatever makes you comfortable I guess.
Over 2 years of your minimum expenses is excessive. That cash is a drag on your portfolio. Cash doesn't even keep up with inflation right now.
Is there inflation? I think we're in deflation or disinflation no? I know prices are going up like eggs but that's more a supply and demand issue. The economy seems pretty flat to me.