Rotation issue with animation exported from Blender

I’m trying to understand what is wrong with Blender animation I’m trying to use in UE5.

Practically what I’m doing is recording mocap in UE5 then export to Blender.

Over there I created a Rigify Rig using UeToRigify plugin.

But I’m facing the rotation issue of bones here and don’t understand why it happens.
Ignore the arm tho.
At first I was thinking it has to be with Quarternion vs Euler rotation (since Quarternion is usually default in Blender), but switching it all to Euler doesn’t seem to make a trick.

Importing back to Blender works fine.
Importing to 3ds Max works fine.