I had to read how the pancakeswap frontend does this.
Basically, you calculate gas for BOTH methods. And the one that does not return an error, is the one you use.
e.g:
contract.methods.swapExactTokensForETHSupportingFeeOnTransferTokens(
Web3.utils.toHex(amountIn), Web3.utils.toHex(0), path, to, deadline
).estimateGas({
from: activeAccount.address,
gas: 5000000,
value: web3.utils.toHex(0)
}, (error, result) => {
console.log(error);
console.log('swapExactTokensForETHSupportingFeeOnTransferTokens: ', result);
});
contract.methods.swapExactTokensForETH(
Web3.utils.toHex(amountIn), Web3.utils.toHex(0), path, to, deadline
).estimateGas({
from: activeAccount.address,
gas: 5000000,
}, (error, result) => {
console.log(error);
console.log('swapExactTokensForETH: ', result);
});