Take for example Google Material design website, that has big sub-menus in the sidebar's menu.
The sub menus are closed on page load.
Material design
Motion
Style
Layout
...
Clicking on a menu title expands its sub-menu
Material design
Introduction
Environment
Material properties
Elevation and shadows
What's new
Motion
Style
Layout
...
When clicking on a different menu title, should the opened sub-menu collapse or not?
Option A:
Material design
Motion
Style
Color
Icons
Imagery
Typography
Writing
Layout
...
Option B:
Material design
Introduction
Environment
Material properties
Elevation and shadows
What's new
Motion
Style
Color
Icons
Imagery
Typography
Writing
Layout
...
In Option A (which might animate) the user's cursor would be over some different element after the sub-menu collapses (not good). Displays the menu in a cleaner way, without the need to scroll.
Option B does not trigger undesired actions (Option A somehow triggers an action). The user might have to scroll to see the just-opened sub-menu. The user might have to close the opened sub-menu to see clearly what he just opened.
What is the user's expectation, which option facilitates user's task?
Edit:
On a side note I just read this on Navigation patterns - expanding navigation drawer:
Selecting a collapsed section expands that level in-line, hiding all levels outside of it.
This looks like Option A. However this is not applied in the same website, that applies Option B.