Recently replaced upstream air fuel ratio sensor on my 08 prius with a denso one off amazon and also replaced my 12v when im accelerating/underload makes a pretty loud rattling noise and also seems like battery drains pretty quick when its happening there are codes being thrown P0031 and P2237 which leads to upstream air fuel ratio sensor not sure if i just got a bad one or its something else giving false code
The trouble could also be in a wire harness or connector, or in principle, in the ECM. The Repair Manual (more info) has step-by-step troubleshooting procedures for both of the diagnostic trouble codes you mentioned. Have you tried those procedures, and if so, what were the results at each step?
Which OBD2 reader are you using to retrieve those DTCs ? Here is the workup for DTC P0031 : https://share.qclt.com/%E4%B8%B0%E7%94%B0%E6%99%AE%E7%91%9E%E6%96%AF%E5%8E%9F%E5%8E%82%E8%8B%B1%E6%96%87%E6%89%8B%E5%86%8Cpdf%E6%A0%BC%E5%BC%8F/Repair%20Manual/04pruisr/05/2054m/cip0031.pdf