The paying bank would typically return the item (the check or electronic check) that was posted to the issuer's account last. If Bank B also accepted the item for deposit as a mobile deposit, and if the paying bank (or its customer) catches the duplicate payment, the mobile-deposited item would usually be returned to the last of the depositary banks to have taken it. That bank would then charge the item back to its depositor, if possible. If that bank sustained a loss, it would have no recourse to the other bank.
If Bank B instead accepted the actual paper check for deposit and the check is returned to Bank B unpaid because the check had already been presented by Bank A and paid, Bank B would attempt to charge the check back to its depositor. If Bank B sustains a loss because there aren't sufficient funds in its depositor's account, and Bank B is not able to recover the funds, Bank B might think it can make an indemnity claim against Bank A under Regulation CC section 229.23(f). However, the Regulation CC provision prevents Bank B from making the claim because the "mobile deposit only" restrictive indorsement that was on the check when Bank B accepted it for deposit is "inconsistent with the means of deposit." It said a mobile deposit was being made, but the deposit was not a mobile deposit.