Bake skeleton pose - converting A pose to T pose

I’m building a DAZ importer and trying to get default A pose exports to work with my T-pose animations.
Here’s what I’m doing:

  1. Importing character in A pose
  2. Applying bone rotation overrides i.e. lShoulderBend {x: 1, y: 0.2, z: 0.1 }
  3. Running baking script which works similarly to STLExporter (code below)
  4. Now the character looks correctly in T pose and rotations are all at 0,0,0

BUT here’s the problem(arms and their children):

Children bones of the changed bone become all messed up. What do I have to do? Here’s my bake skeleton script

function bakeSkeleton ( target ) {
  var v1 = new Vector3();

  target.traverse( function ( object ) {
    if ( !object.isSkinnedMesh ) return;
    if ( object.geometry.isBufferGeometry !== true ) throw new Error( 'Only BufferGeometry supported.' );

    var positionAttribute = object.geometry.getAttribute( 'position' );

    for ( var j = 0; j < positionAttribute.count; j++ ) {
      object.boneTransform( j, v1 );
      positionAttribute.setXYZ( j, v1.x, v1.y, v1.z);
    }

    positionAttribute.needsUpdate = true;

     // commented out stuff is where I tried to apply rotation matrix to children's inverse matrices
    // const orgUninverse = new Matrix4();
    // const q1 = new Quaternion();
    // const mat = new Matrix4();
    // const inverse = new Matrix4();
    object.skeleton.bones.forEach((bone, i) => {
      // q1.copy(bone.quaternion)
      // mat.makeRotationFromQuaternion(q1)

      bone.rotation.set(0,0,0);
      // bone.updateMatrix();
      // bone.children.forEach(child => {
      //   const bid = object.skeleton.bones.indexOf(child)
      //   if (bid === -1) {
      //     console.log('bone not in skeleton', child.name)
      //     return
      //   }
      //   console.log('bone fond', child.name)
      //   orgUninverse.getInverse(object.skeleton.boneInverses[bid])
      //   orgUninverse.multiply(mat.makeRotationFromQuaternion(q1))
      //   object.skeleton.boneInverses[bid].getInverse(orgUninverse);
      // })
    })
  } );
}

Update:
Much easier way of changing the starting pose is applying deserved rotations(but inverted) and calling skeleton.calculateInverses(). The pose gets applied correctly and all rotations are 0,0,0 but again during animation the same problem occurs

It’s even stranger now.
Setting all bones’ rotations to 0,0,0 gets to the desired T-Pose (seems like it worked)

But calling skeleton.pose() sets the skeleton in the original A-Pose. Now this is getting interesting.