@mx1 No. No need.
Anyway the conditions you posted don’t make sense:
if ((updatedProductData.variants.length && product.manageVariants)
|| (!updatedProductData.variants.length && product.manageVariants))
This is logically almost equal to if(product.manageVariants) (the only difference is that in your code there will be an error in case updatedProductData doesn’t have the variant property). So what’s the point?
Try to console.log() the results of each step. For example:
console.log(updatedProductData);
Maybe it’ll help you to locate the problem.