Suppose your Pidgin client is logged into one of these 2 servers (say user2@companyA.com). Then you will have no problems adding other companyA.com users. To be able to add companyB.com users you will have to enable and configure server to server connection on both servers. You will find it in the Server settings in Admin Console.
As i don’t use server to server myself, can’t help much in this. I have tried to setup such connection at home with an external server but never managed to achieve that. This could be also a DNS related issue as those servers should be able to “see” each other.