Magento doesn't natively allow you to apply multiple coupon codes to a specific order. So having a coupon code for free shipping AND using a coupon code for 40% off wouldn't work.
What will work, and works natively in 2.4 and should work in 2.3, is using two separate cart price rules. You would set up a generic rule to provide free shipping on carts with a subtotal of greater than $50. Then you'd create a normal coupon code rule that applies the 40% off to the specific items.
Here are two example rules:
- Generic Free Shipping Rule
- Coupon: None
- Free Shipping:
- For shipments with matching items
- 40% off Rule
- Coupon: Whatever you want the code to be
- Conditions: Whatever your rule conditions are
- Apply: Percent of product discount
- Discount Amount: 40
The reason this works is because the cart price rules operate at the cart level. While the discount is calculated per-product, they are combined into one discount that is applied after the subtotal. This would not work if you used catalog price rules, since these types of rules will adjust the price of the line item which will affect your subtotal.