Maybe easiest of the options is applying filter method to your getByText().
const buttonsCount = await page.getByText('(Optimal on desktop / tablet)') .filter({ visible: true }) .count()
See Matching only visible elements