In my younger, crazier days when I was OK with giving up work/life balance, I dealt with this by not really trying to get things done in the office (by which I mean not bothering trying to reach or maintain flow state). Instead, I'd mostly warm my office chair and do my real work after hours at home.
Now, though, I think "screw that". I want a life. So I just found a way to accept that working in an office environment means that I won't be able to do my best or most efficient work and don't worry about making up for it on my off time.
On days I go to office I focus on being present physically so my attendance is noted.
The commute (1 hour each way through dust and traffic) tires me out and I don't get much done that day either work wise or on personal front and go to sleep tired and early.
For remote work days I am able to take breaks in between and come back to desk when feeling productive and energetic. And I mix in some personal work during the day or office work till 8 or 9 PM as I feel like that day.
Now, though, I think "screw that". I want a life. So I just found a way to accept that working in an office environment means that I won't be able to do my best or most efficient work and don't worry about making up for it on my off time.