Hi, @Sumner, Ann
Thank you for posting in Microsoft Q&A forum.
I'm afraid we cannot migrate data from two source hierarchy with the same site code, we may change the site code and site name by modifying the database, but it's not supported by microsoft.
We may try to backup A and recover to new site , and then migrate B to new site.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.