Why retargeted skeleton twists on IK (UpperBody IK)?

I have a skeleton from the POLYGON Samurai asset, which animations were retargeted from the ThirdPerson Mannequin. They play correctly, but when I try to use UpperBody IK (UBIK) to solve head and hands, the result is a twisted mesh. I’m new to animations on Unreal and I would like to know why this is happening and / or hints to find the cause. IK with UBIK was working properly on the original Mannequin. Retargeting was done following [this tutorial][1]:

Animation BP:

State machine:

Result (a very sad twisted samurai):