Animator.applyBuiltInRootMotion ignoring previous transform.position set

I am setting the position of a game object like this:

gameObject.transform.position = pos

Then, in the same frame, OnAnimatorMove is being called and the animator calls applyBuiltInRootMotion. The current animation is Idle, so the character is supposed to stay in place. I expected that after the calling of this function, the gameObject position should be pos, but it is actually the previous position before setting to pos; It is as if the animator didn’t process the position change and is applying the root motion based on the old position.

Is this a bug or is the expected behavior? If so, is there a way to “update” the animator after the position assignment?

Anyone?