From the picture the fluid looks to be dirty.
So, let's recap, did it drive before you changed the sensor/fluid?
Or did it always have hard shift after everything warms up?
Let me know if you have gotten any other codes?
The Code P1731 is a trouble code for the shift control system, typically due to an issue with shift solenoid.
I have attached the diagnostics for that code below.
Image (Click to make bigger)
Wednesday, October 6th, 2021 AT 7:31 PM