Auto-append a Staff Notice when a member is part of a group

I’ve tried using JS to auto-append a staff notice to an auto-generated account if it is a member of the group “autogenerated” but I’m not sure where I’m going wrong.

<script>
   window.onload = function() {
     const { groupMembers } = await discourse.groups.getMembers({
       group_name: 'autogenerated'
     });

     if (groupMembers.includes(helper.getModel().user_id)) {
       return helper.h('div.post-notices', [
         helper.rawHtml(iconHTML('shield-alt')),
         helper.h('p', 'This account is auto-generated and should be considered as a bot. The account is not monitored by Staff.')
       ]);
     }
   }
 </script>

I’ve put the code in the “Head” part of our component, however, it’s not running. I’m not sure if it isn’t calling the function correctly, or if my IF statement suddenly isn’t being met.