It mat be cheaper/easier/quicker to swop in another engine if you can find one. Costing when the actual damage is yet unknown is unlikely to be successful.
Have you considered eBay?
https://www.ebay.co.uk/p/19056834021
May fit? I don't have any knowledge of this item (my OB has old-style steering) but if you can find a compatible unit, may help?
As for coding, no clue. Out of my depth on that one.
Good luck with doing hg yourself. **** luck it's happened that the 3.0 is suffering hg in the first place as those motors rarely suffer such failure.
I understand doing a 3.0 hg replacement is serious work - have you've previously done this sort of work so realise exactly what you are getting yourself into?
I wonder if the car has passed an MOT as failures can come if the MIL is on at time of test. Assume you've checked transmission fluid level as needed? Did the lambda sensors get changed before or after the faults appeared?
Is the car temperature within normal range/s when this happens? If the temp gauge isn't consistently at the "9 oclock" position when running, you may have bigger problems. Is the thermostat you installed oem (Subaru) or generic? When you fill the radiator do you burp the cooling system to ensure no trapped air remains as these cars can be tricky in this regard.