There are several ways to provide Free Shipping. In your case you are doing it through the Table Rates but if you want to get the correct result I would recommend to use a Cart Price Rule to provide free shipping.
More information how you can configure a Cart Price Rule see https://docs.magento.com/m2/ce/user_guide/marketing/price-rules-cart.html
Determines if free shipping is included in the promotion, and if so, for which items. Options:
Free shipping is not available when a coupon that is based on the rule is used.
For matching items only
Free shipping is available only for specific items in the cart that match the rule.
For shipment with matching items
Free shipping is available for the entire cart when a coupon that is based on the rule is used.
But if you really want to do it through a cod changes then take a look around line 101 and 12 in file:
Here you can change the getPackageValue to getPackageValueWithDiscount.