Can my friend transfer his Pokemon to his Pokemon home then unlink the 2 accounts and then I link my Nintendo account with his bank and then pack the Pokemon from my old versions onto the bank and then bring them over to my home?
If you disconnect a device from a Nintendo Account, all data belonging to the account, including software and license, will be deleted from the device. As far as the transfer from bank to home is concerned, only a transfer password is required as far as I've seen, but I didn't go any further, so you only have the following options
1. If you have a premium home account but don't have a bank that you can get a bank and then go the normal way, or if you only need a transfer password so that you can transfer the Pokemon to your bank and then to your home
2. If you don't have a premium home account, you either have to get everything you need or you transfer the Pokemon to your friend's bank, then to his home, if you have a bank and a transfer password, you could only then send it to your bank and then on his home and then in laborious detail work the Pokemon over to your home using the exchange function.
Hm but it is already connected to a nintendo id, so the 3ds. Doesn't that just leave everything as is?
No, the purchased items are linked to the ID, and if the device is disconnected from the ID, all items linked to the ID are also removed from the device, otherwise users could eventually access items for which others have paid.
I hope that answers your question, because it is not very clear (to me) what exactly you mean by your question.