Confirmation email show the "compare at price" for only on sale items?

I would like to have the order confirmation email show the “compare at price” for only on sale items.
I figured out how to put in the “compare at price” for the products in the email via HTML, but, it is listed for every item in the order.
Is there a way to have the “compare at price” only show when the item is on sale in the confirmation email?

I did figure out how to put the “compare at price” into the confirmation email via the html template, but it shows on all the items, not just the on-sale items.

This is how I did it:

Go to Settings (bottom left of page gear icon) → Notifications → Order confirmation (first item) → then hit ctrl F for find on page and search for “price”

Under the line: {% if line.final_line_price > 0 %}

Put this code:

DLW_0-1622140568809.png

And the pre-view looks like this: