Change the default group pages to /messages

They’re not regular links. They’re handled with a link-to Ember component, and there’s a little bit of routing involved.

The easiest way to do this is to hijack the click on that element and do your work there. This goes in the common > header of a theme

<script
  type="text/x-handlebars"
  data-template-name="/connectors/group-index-box-after/link-to-group-inbox"
></script>

<script type="text/discourse-plugin" version="0.8">
  const DiscourseURL = require("discourse/lib/url").default;
  api.registerConnectorClass('group-index-box-after', 'link-to-group-inbox', {
    setupComponent(args) {
      const group = args.model;

       if (group.is_group_user && group.has_messages) {
         const groupLink = document.querySelector(`.group-box.${group.name}`);
         const newHref = `/g/${group.name}/messages`;

         // updates browser title and handle new tab
         groupLink.href = newHref;

         // redirect the link
         groupLink.addEventListener("click", (event) => {
            DiscourseURL.routeTo(newHref);
            event.preventDefault();
         }, {once: true})
       }
     }
  });
</script>

If the user is a member of the group and the group has messages, it will redirect to the inbox. Otherwise, it will fall back to the default /members page.