Hi,
System is recognized based on debit or credit indicators of the GR/IR balance. However, in your case the inventory has returned. Then at the time of goods receipt the GR/IR has created. When you return the goods the GRIR balance gets debited and both debit/credit will be nullified.
Regards,
Mukthar