Valuation heuristics have flaws
Profit margin does not have a profitability monopoly. Two companies with similar margins have different profitability depending on their asset efficiency.
Return on Invested Capital ("ROIC") = NOPAT/Sales ("profit margin") x Sales/Invested Capital ("asset turnover"). High margins hint at differentiated products, while a high asset turnover implies cost leadership.
The "rule of 40" is now a standard valuation tool and equals sales growth % + a profit margin %. Asset efficiency is not explicitly rewarded or, in the case of companies trying to disguise as software firms, punished!
Enter "Magic number"
Long-term prospects are likely better for Company 1, even though both firms have the same R40 score. Because Company 1 has a higher return on S&M.
So company 1's higher R&D investment (expensed over IS..) should give higher future returns. Company 2, on the other hand, has less room for R&D as more cash is burned on S&M to achieve similar growth.
Disclaimer - a screen does not take into account 'Legacy Moats' vs. 'Reinvestment moats'
ROICs/R40s/Magic numbers are not created equal. High returns on invested capital (sunk investments) are not valuable without opportunities to deploy incremental capital at high rates. It is only a proxy of what to expect.
P.S. Yes, determining invested capital is an arcane science for the Patagonia initiated few. Chinese books also illustrate how accounting numbers are but opinions: