Why not change the statement completely to only set this state when the line items are empty? if the line items are completely empty for this order, then the payment state should be set to 'emptied'. I think this should be the first thing that's checked in the `payment_state` if-chain, rather than one of the last things.

Could you please rework it to do this?