I went down the same road, new upper O2 sensor, new EGR, etc..
If you are getting a P0171 (Bank 1 lean), don't discount a weak or worn out fuel pump or fuel pump assembly.
I had been dealing with that code (and a P0300 - Random multiple misfire) for over a year. Turned out the pump and a...