Discount function results are correct, but cart is wrong

Hey Shopify Team and community.

We have a shopify app which is live and public, and have a discount function in the app.

The problem is, that we are generating the output to set the 100% percentage discount on a specific line item, and when user updates the line item’s qty in cart from 1 to 2, or 3 or more, they get all of the qty discounted, not one.
I tested this multiple times and debugged the logs with different cases in the cart, and it always does the same.
Pasting screenshots of log and cart items here.

This is the func output

for this cart

{
  "cart": {
    "lines": [
      {
        "id": "gid:\/\/shopify\/CartLine\/0",
        "quantity": 3,
        "cost": {
          "amountPerQuantity": {
            "amount": "0.0"
          }
        }
        
      },
      {
        "id": "gid:\/\/shopify\/CartLine\/1",
        "quantity": 1,
        "cost": {
          "amountPerQuantity": {
            "amount": "29.99"
          }
        }
      },
      {
        "id": "gid:\/\/shopify\/CartLine\/2",
        "quantity": 1,
        "cost": {
          "amountPerQuantity": {
            "amount": "29.99"
          }
        }
      }
    ]
  }
}

What are you seeing in the cart AFTER the function has run? I think it’s worth noting that applying 100% off to a $0.00 product, the discount doesn’t actually get applied.

Yes @bkspace .
Thank you for pointing out. So dumb am i, :smiley:
The user had the product set to $0. hahahah