What makes you think that
DeclineGroup is "not working" ? If you think that because it's not hiding the invitation popup, you are mistaken -- you need to either hide the popup yourself (declining a group doesn't cause any event to fire, so the popup can't detect when you decline and hide itself) or just hide the popup instead of calling
DeclineGroup (since it
does that automatically when hidden).
If you're trying to do something other than "automatically decline groups and hide the popup" please be more specific.