@Yakshitha 

you are using wrong syntax and wrong variable name, I highlighted the changes you need to do

I shared gs.getUser().isMemberOf(groupAId)

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader