Since the bike's dropouts are damaged from the axle spinning out, you'd be better off to install clamping dropout torque plates on both sides, than to change the axle. Then you won't even need the axle nuts, because the dropout clamps will hold the flats and prevent any movement.
Note that a clamping dropout torque plate is NOT just a torque arm. If you look thru the Torque Arm Picture Thread you'll see pictures of both types.
Also, you'll probably have to re-cable the motor anyway, replacing the phase/hall wiring cable starting from inside the motor, to ensure there are no damaged wires inside the twisted motor wire cable. Even if there is no apparent damage externally, there could be inside the cable housing, even the part inside the axle itself, and if the insulation between any pair of wires in there fails from that, it could damage the motor (halls) and / or the controller (fets, mcu, power supply, etc).