Looks like another Calc bug:
In A1:A5 enter Test, 1, 2, 3, 4 and Autofilter it.
In cell A5 enter formula: =SUBTOTAL(109,A2:A5)
Click the Filter dropdown arrow and notice the subtotal is now part of the filtered rows. Is that expected?
Select Column A and clear the filter then reapply to Cells A1:A5. Click elsewhere then click the dropdown. Cell A6 is back in the filter. Even if a blank row is left above the subtotal it is included.