Another way to reproduce the “unexpected unfold” behavior is to create a heading that’s long enough to wrap to a second line
# This is a very long heading that will most likely wrap to two lines in the editor
This is content inside the heading
# This is a second heading
If you fold the first heading, then use J to move from that heading to the second heading, the first one unfolds.