Time table where workers overstay past midnight
It can be tough to come up with a definitive solution without having your data, but here's a few ideas that I would consider if I was having to solve this problem.

Since you have the full date and time in your data table, you could store that in your time table, and just display the time part of the date/time.  Then your elapsed time calculations would be simplified because you can use the difference between arriving and leaving that you're already calculating in the sheet.

Alternatively, if you could change your time table to allow multiple entries in one day for each person, you could have the person "leave" at midnight (23:59:59 or 24:00:00) the day the arrive, and "arrive" at 00:00:00 the next day.  This would still require some complexity in the time calculations.

If those ideas won't work for you, you can make a small improvement in your "hours" calculation.  The last part of it (MAX(D11-D10-(1/24),0)) is overly complicated.  You've just checked that (D11-D10)&lt;(4/24), you know that D11-D10 will be >= 4/24, so the MAX calculation could just be D11-D10-(1/24).