enc: Move out group session lookup into a function

We are doing this a lot, let's move them to a function
so that we have one place to look for errors
2 jobs for wip/sadiq/various-fixes in 3 minutes and 15 seconds (queued for 4 seconds)