The problem is very simple. Since the last update of R (version 4.3.xx), the basic function cut applied to Posixct objects had a bug when reaching midnight...
Here is a basic reproducible example:
tmp=seq(ISOdate(2023,1,1,23,55), ISOdate(2023,1,2,1,1),"s",tz="UTC")
tmpBreak=cut(tmp,breaks="hour")
unique(tmpBreak)
2023-01-02 should be written 2023-01-02 00:00:00 otherwise, reversing the factor value in a posixct leads to a NA value.