During the research over some of the unposted transactions, it was found that the customer party Id is getting set as organization party Id for one of the transactions belonging to a customer return invoice.
Steps to regenerate:
Simply create a return and receive it so as to eventually generate the return invoice. Inspect the return invoice's transaction. One of the transaction would be containing the customer party Id as the organization party Id.