FIX: Avoid highlight mention to groups that are not public.

FIX: Avoid highlight mention to groups that are not public.

Follow-up to 3f5048118802116679ef28c32728f697cbfb8404.

diff --git a/app/assets/javascripts/discourse/lib/link-mentions.js.es6 b/app/assets/javascripts/discourse/lib/link-mentions.js.es6
index 68d0b8b5d6..f3bbbe3797 100644
--- a/app/assets/javascripts/discourse/lib/link-mentions.js.es6
+++ b/app/assets/javascripts/discourse/lib/link-mentions.js.es6
@@ -46,7 +46,7 @@ function updateFound($mentions, usernames) {
       const username = usernames[i];
       if (found[username.toLowerCase()]) {
         replaceSpan($e, username, { cannot_see: cannotSee[username] });
-      } else if (foundGroups[username]) {
+      } else if (mentionableGroups[username]) {
         replaceSpan($e, username, {
           group: true,
           mentionable: mentionableGroups[username]
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index ac6d16f13c..64b1152a1f 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -308,7 +308,7 @@ class UsersController < ApplicationController
     groups = Group.where(name: usernames).pluck(:name)
     mentionable_groups =
       if current_user
-        Group.mentionable
+        Group.mentionable(current_user)
           .where(name: usernames)
           .pluck(:name, :user_count)
           .map do |name, user_count|

GitHub sha: 67c9940d

There should be a test for that :wink:

https://review.discourse.org/t/dev-add-test-8961/9085