I found the fix in another thread. Here it is -
Settings --> Device Care --> Battery --> 3 dots --> Settings Optimize Settings --> Turn OFF
And it WORKED. No more timeout issues
Much better option which I would recommend is - Follow same steps as above. Do not turn off Optimize Settings. Instead touch on it and you will see 3 more options under Optimize Settings. Here turn off Screen timeout.
Update: Turning off adaptive battery also did not fix the screen timout bug. In the morning back to 30 seconds. This is very annoying, specially not knowing what is causing it.
I do not see a reason to use medium power saving. If the timeout screen is not functioning like it should then that issue should be fixed. Using medium power saving is not the solution, sorry.
I recommend taking the phone to a local uBreakiFix and having the software reflashed. This sounds like there is an issue in the software configuration. https://www.samsung.com/us/support/ubreakifix/