P0407 is indicating a fault in the EGR valve electrical circuit.
Potential causes of a P0407 code include:
Short to ground in EGR signal or Reference circuits
Short to voltage in EGR ground or signal circuits
Bad EGR valve
Bad PCM wiring issues due to chafing or loose terminals
Ideally you would hope the garage tested the valve first before changing it but the code points to a defective valve. It is possible the temp sensor fault was masked by the EGR valve fault or that the failed temp sensor caused the EGR valve not to work correctly. A full diagnosis at the time may have shown that one or both parts needed replacing. However, if you are saying the light came on immediately after the EGR was replaced then the garage should really have done more checks using live data for the voltage feedback from the EGR, the actual versus the commanded position and then used the actuator menu to operate the EGR valve after removing it from the engine then reconnecting the plug to test it.