Without all the facts, all I can do is identify issues.
Who has the money? If Participant A has the money, then he had some notice of the problem and would bear some responsibility if the loan is in default. If payroll loan payments are made each month or more often, Participant A is probably operating in a grace period 2 loan payments behind (provided the loan agreement provides the maximum permitted grace period). If payroll loan repayments are quarterly, the loan is in default.
If the Plan has the money in Participant B's 401(k) account (or otherwise credited to Participant B), you have a simple misapplication of funds that can be corrected by the Plan.
If Participant B got a check, you have a prohibited transaction = the Plan paid Plan assets to an interested party that was not entitled to receive them. Participant B must receive a demand letter for the funds plus interest (and sued upon failure to repay if this would be financially reasonable). Until Participant B repays, the employer must deposit the funds into Participant A's account with interest. I would treat the loan as timely paid since it was; the recordkeeper failed to keep an accurate record of the payments due to the faulty SS#.
If there was a prohibited transaction, it should be reported and the penalty paid by the employer.