Collapsing a group with batchPlay can be done using:
await batchPlay(
[
// collapse current selected group
{
"_obj": "collapseAllGroupsEvent",
"_isCommand": true,
"_options": {
"dialogOptions": "dontDisplay"
}
}
],{});