It may be helpful to understand that there is only one engine. The majority of the time it is running, in my experience, it is just producing electricity which is sent to either the electric motor, the batteries or both. Even in EDM, the engine can generate electricity. The difference is that the engine is also directly driving the wheels while in EDM.
In EV Mode, electric current is provided by the battery, unless a certain power demand is exceeded, at which point the engine will provide additional current to the electric motor.
In HV Mode, the engine generates electricity which is sent to the motor and batteries as needed. The engine/generator can only provide about 60hp to the wheels. If more than 60hp is required, additional current will be drawn from the battery. Once power demand is reduced, the engine/generator will work to restore (recharge) the battery to the previous level while also sending current to the motor.
Perhaps the answer to the question is that these transitions are controlled by software, based on the driving conditions. Outside of EDM, we are looking at a vehicle where electricity provides the motive power which is provided by either the engine/generator, the battery, or a combination of the two.