I am working on my wife's cousin's vehicle. 2008 Scion XD, 1.8L, 152k miles.
I replaced all 4 spark plugs and ignition coils and cleared some misfiring codes. I am currently in the process of replacing the upstream O2 Sensor due to code P2237 which is causing failure mode and cannot accelerate past 30mph.
As of now, when in gear, drive or reverse only, the engine bogs down to less than 500 rpm and feels like stalling out but doesn't.
Any help or suggestions would be appreciated, thank you
Something is loading the engine when in gear. When was the last transmission fluid and filter change? Have you checked for a clean air filter and MAF sensor, egr valve and pcv valve?
Either something is suppling the engine computer the wrong data, or there's an issue with the mixture.
From my experience with these ZR engines, the only thing that goes wrong with them is carbon build up on the throttle - so I recommend you check that first! that engine was very popular in Europe and that was the cause of 90% of failures (other than oil consumption)
As far as the rest, as @Doc said, you might want to check the MAF, EGR, PCV and replace the Air filter.
Also, maybe a battery reset may help - Toyota ZR engines relearn idle position each time you disconnect the battery (that's why they tend to stall after starting for the first time with a new battery) so that might be the issue.
You might want to check if for Vacuum leaks, Also, I'm not sure if that happens on ZR engines, but on other engines MAP tends to cause these symptoms (when the car's off the MAP should display 1 atm or 14 psi so that's quite easy to check with a scan tool)
Additionally, if this happens after you replaced the O2, do the O2 sensors cycle correctly (I hope you're using OEM, often Chinese O2 sensors are the reason for most issues in the first place) and have what'd be considered normal values (cycle from 0 to 1 volt, without going out of these bounds) and are they both reads similar values or is one pinned rich and another pinned lean?
Maybe running it in open loop will help?
Also, if it's none of these and the engine is getting all of the correct data, and there's no issues with the air supply (Throttle, MAF, MAP, PCV, EGR, Vacuum leaks) I'd check the fuel system - does the fuel pump in the tank sound bad? is there's enough pressure on the fuel line? if not that, maybe the injectors aren't injecting enough? try priming the fuel pump while checking the fuel pressure and go between all injectors seeing how much each injectors takes off from the same initial pressure after the priming - do all injectors subtract the same amount of pressure from the line?
These ZR engines are very well built, so it's probably something in the sensors / equipment that's making it act up.
I agree with @dan that a dirty throttle body is a likely culprit. I could not find any information about the 2008 XD, but I found this video where a low idle like yours is diagnosed and resolved on a 2011 Scion XB 2.4L by performing a throttle body cleaning and subsequent idle re learn with a scan tool. The video is a little lengthy but very informative. Good luck.