The lender is Company A, and if it is unable to repay, it will be its guarantor. What does it have to do with company B?
Generally speaking, the bank lends money to company B, which shows that it is impossible for company B to be the guarantor of loan A.. As for how B will use the money, the bank has no right to interfere.