Forget about 40 MPG. Low 30s highway, high 20s city. You might see mid 30s if you can keep your speed down to 60 MPH on a long stretch of freeway but this car is so much fun to drive fast that I doubt you'll be able to. The 90-liter (23.8 gallon) fuel tank gives you a range of 700+ miles at low-30s MPG, which is great.
My car had significant work (by the second owner) on the wiring system, new engine mounts, serpentine belt tensioner, etc., before I got it. The first owner had the car repainted (quality work, fortunately). I got the car at 190K in what many folks would call "perfect" condition and paid $4700. Newer diesels tend to sell for a little more here in California because of their relative rarity. The only significant mechanical work I've done was to replace the front flex disk; everything else I've done has been cosmetic stuff and regular maintenance.
At 240K you'll want to replace the vacuum pump just for safety's sake, and there may be suspension items and other things to fix. I'd be cautious about shelling out a lot of bucks for what you describe as a car with significant question marks being sold by a flipper (who therefore doesn't know much about it).
Jeremy
__________________

"Buster" in the '95
Our all-Diesel family
1996 E300D (W210) . .338,000 miles
Wife's car
2005 E320 CDI . . 113,000 miles
My car
Santa Rosa population 176,762 (2022)
Total. . . . . . . . . . . . 627,762
"Oh lord won't you buy me a Mercedes Benz."
-- Janis Joplin, October 1, 1970