The only thing that confused me was the term, "XO" referring to the late night captain. I always thought the XO and commander were the same things
They are, outside of NF. PAD needed a co-First Officer for the story, so he came up with that notion. Honestly, it's the most thought Star Trek has ever given to the practical requirements of operating in a truly round-the-clock environment (even 24-hour jobs on Earth are affected by the fact that, when it's night, things are less busy), and even then, it just writes off the third-shift as a bunch of seat-warmers.