Do not get side tracked or you are spending good money and still have a truck that doesn't start or run worth a damn. New parts don't mean good parts so you can cause additional problems by replacing "working" parts with defective new parts. Ruining out of fuel gives the optical sensor foam and screws up it's readings. Removing the sensor is asking for trouble unless your are 1000% it's bad. Clearly we are not at that step so the best advice is to leave it alone.
Troubleshoot it rather than throw expensive parts and hope at it.
Test the old batteries separated from each other. Parts stores can do this for free. Simply put bad batteries need to be the first thing corrected and
make sure they are indeed bad before dropping coin on them. Depending on age replace them in pairs. First year you can get away with warranty of one, otherwise, the older battery pulls down the new one and ruins them both quicker.
Air. Air in the fuel system is the first thing in the GM manual for fixing these diesels. Grounds are #2.
@Will L. advice above for the clear return line and lift pump test is sound. I check lift pump pressure at every oil change (2500 miles: severe duty) and others run a dedicated fuel pressure gauge.
Yes, it's that important.