Hi,
I wonder what the authentication issues are that you mentioned., but for the hierarchies, I believe you will need to need to send out the parentId field from A and then process it on B to find the correct parent, and link it.
This should be a good starting point (concentrate on the Jira incoming piece here): Jira Cloud Azure DevOps: Bi-directional hierarchy sync
For tasks-subtasks this should help: How to Sync Tasks and Subtasks in Jira Cloud
Please provide the scripts you have on B incoming and maybe I can point you in the right direction if you get stuck.
Thanks
Majid