I know it's been a bit, but for anyone with a similar problem, here's the code I came up with.
If you reached your activity limit (default: 100) you'll need to export xml your workflow version, increase the max_activity_count value and import the xml...
Fantastic work on this! Any chance you can show how you got the "Use Suggested Group" button next to your reference field? I can't seem to find anything in ServiceNows docs about that.