The trick is to create a helper column with a formula like:
=SUBTOTAL(103,A2)
Assuming there's something in A2, this formula result is 1 if the row is visible, and 0 if row is hidden. You can then include the helper column in your SUMIFS or SUMPRODUCT calculation as a criteria column.