I was able to recreate that error message by sending a curl with no XFF header to a VS with this iRule attached. I suggest going over the datagroup, ensuring that it is set to 'type: address', and checking to make sure the requests sent have an XFF header. Also do note that this iRule expects the value of the datagroups to be set up as the names of preconfigured snatpools. If you want it to SNAT to the IP address that is defined in the datagroup, change
NAT traffic according to xforwarded-for header
snatpool $category
to this
NAT traffic according to xforwarded-for header
snat $category
Once I solved those issues, I was able to get the iRule to function properly.
If you have any more questions, I am sure I can help.