You’re not missing anything. If you invested in mid to long duration bonds right before the Fed started rocketing rates, you had a bad time.
I invest in treasuries when interests are high or gonna stay high. If i see us hitting a recession in coming year, i keep mostly cash and start piling into treasuries over each hike cycle until at least the central banks start cutting rates and keep riding the treasuries till rates keep moving down.
Or in other words, dont fight the fed