Seems logical to me
You said the engine ran fine when first started (below operating temp) or when you unplugged the TPS sensor and created an operating fault which forced the ECU to run back in open loop mode. In this mode the ECU pretty much determines the amount of fuel to provide by the barometric pressure sensor, coolant temp sensor, Vaf(flapper door and air temp), and the RPM.
When the engine gets to operating temp and there're no major faults, it goes into closed loop mode. In this mode and the engine running at a steady RPM, the ECU will use the feedback of the O2 sensor to help adjust the fuel.
Those ground wires that connect at the thermostat housing run directly back to the ECU to provide the ECU with an engine ground reference point. This is important for the proper operation of the ECU to determine the true state of the O2 sensor. The O2 sensor only has a range of 0-1 volt, if it's below .5V the ECU read it as lean, above and it's rich.
With the engine reference ground disconnected, the ECU ground started to float a little and created a bias that made the ECU interpret the O2 sensor's signal as being higher than it really was.