Thanks for the partial fix.
Unfortunately there is still something strange going on as the last heading gets hidden. Added some more headings to demonstrate this better:
This is the unfolded file content:
* Heading Lvl 1
** Heading Lvl 2 with VISIBILITY content
:PROPERTIES:
:VISIBILITY: content
:END:
*** Heading Lvl 3
** Another Heading Lvl 2
* Formulas
** New Ones
*** LET
*** LAMBDA
:PROPERTIES:
:VISIBILITY: content
:END:
*** XMATCH
*** XLOOKUP
* Dynamic Array Formulas
After using org-cycle-content followed by org-cycle-set-visibility-according-to-property I get this:
* Heading Lvl 1
** Heading Lvl 2 with VISIBILITY content...
*** Heading Lvl 3...
* Formulas
*** LAMBDA
* Dynamic Array Formulas
Whereas the expected output should look as follows:
* Heading Lvl 1
** Heading Lvl 2 with VISIBILITY content
*** Heading Lvl 3
** Another Heading Lvl 2 (missing)
* Formulas
** New Ones (missing)
*** LET (missing)
*** LAMBDA
*** XMATCH (missing)
*** XLOOKUP (missing)
* Dynamic Array Formulas
Setting org-fold-core-style to overlays doesn't change the outcome.