How to disable showing the discount code visually when the script doesn't apply the discount code

Topic summary

Shopify checkout issue: a Script Editor line-item script is used to disable discount codes, but when a customer enters a valid code that the script prevents from affecting pricing, the code still appears visually under the discount input field. This creates confusion because customers may believe they successfully received a discount even though the cart total doesn’t change. The request is for a way to hide or prevent the discount code from displaying in the checkout UI when it isn’t actually applied, while still allowing gift cards to be used. An attached screenshot shows the discount code still listed despite no discount being applied. No solution or resolution is provided in the post; the question remains open.

Summarized with AI on February 26. AI used: gpt-5.2.

So I’m using a script to disable discount codes. I’m using this script to be specific.

https://help.shopify.com/en/manual/checkout-settings/script-editor/examples/line-item-scripts#disable-discount-codes

The problem is, when someone enters a valid discount code although it doesn’t affect the price in the cart it still shows visually below the box. This might mislead customers to think that they’ve ‘hacked’ the system and got a discount even when the policy clearly states otherwise.

Is there a way to visually not show the discount code? I would like to allow Gift cards to be used.