I’m not sure you can expand a group programmatically.
One approach / workaround could be to create a group at the very first step of your recorded action. Before adding layers that you want to have inside that group. Make sure to select that new group, and then add adjustments layers to it. The group should remain open at all times.
Further, collapsing a group with batchPlay can be done using:
// collapse current selected group