Dirty or old transmission fluid: Change the transmission fluid and filter.
Faulty shift solenoids: The shift solenoids control the flow of fluid to the transmission's hydraulic circuits, which engage the different gears. A faulty solenoid can cause the transmission to shift hard or lose overdrive.
Faulty torque converter: The torque converter is a fluid coupling that connects the engine to the transmission. A faulty torque converter can cause the transmission to shift hard or lose overdrive.
Internal transmission problems: If the transmission has internal problems, such as worn gears or damaged clutch packs, it can cause the transmission to shift hard or lose overdrive.
Since the issue clears when the vehicle sits off it could be a computer that controls that function.