By adding a 1N4148 diode across pins 1 & 8 of the IP5306 the M5Stack is forced to turn on whenever the power is connected to the USB port. Note that if you do this mod it will mean that you won't be able to switch off the M5 whenever power is connected but for my application this doesn't matter. I need the M5 to be on whenever power is connected.
I've used a PROTO module to house the MAX40200 and connected as per the schematic above. My program sets GPIO2 HIGH in the setup loop and after detecting that power has been removed, and completing required house keeping routines, it will set GPIO2 LOW which switches off the MAX40200 and removes VBAT from VCC_5V.