Is the cashier who was helping the customer shop the only cashier ringing people up? If not, the person shouldn't be standing at their register waiting: they should be waiting in line for help from a cashier who is actually at her register.
If there is just the one cashier, then yes, I think the customer who is with the cashier and getting her help, and then gets walked to the line, would go first, because that person had the cashier's attention/ assistance first, so they should finish their time with her by completing the transaction before someone else is helped.