Don't show user-header when multiple owners exist

https://imgur.com/a/7BLGNr9

Google-Bug-Id: b/271100476
Release-Notes: skip
Change-Id: Icda524970b937a2e0a3b34f1d60c94bc9aab1248
diff --git a/polygerrit-ui/app/models/views/search.ts b/polygerrit-ui/app/models/views/search.ts
index f3b803b..2edc540 100644
--- a/polygerrit-ui/app/models/views/search.ts
+++ b/polygerrit-ui/app/models/views/search.ts
@@ -16,6 +16,7 @@
 import {NavigationService} from '../../elements/core/gr-navigation/gr-navigation';
 import {RestApiService} from '../../services/gr-rest-api/gr-rest-api';
 import {GerritView} from '../../services/router/router-model';
+import {accountKey} from '../../utils/account-util';
 import {select} from '../../utils/observable-util';
 import {escapeAndWrapSearchOperatorValue} from '../../utils/string-util';
 import {encodeURL, getBaseUrl} from '../../utils/url-util';
@@ -168,8 +169,11 @@
     ([query, changes]) => {
       if (changes.length === 0) return undefined;
       if (!USER_QUERY_PATTERN.test(query)) return undefined;
-      const owner = changes[0].owner;
-      return owner?._account_id ?? owner?.email;
+      const ownerKey = accountKey(changes[0].owner);
+      if (changes.some(change => accountKey(change.owner) !== ownerKey)) {
+        return undefined;
+      }
+      return ownerKey;
     }
   );
 
diff --git a/polygerrit-ui/app/models/views/search_test.ts b/polygerrit-ui/app/models/views/search_test.ts
index e2e02f5..6ca8dc8 100644
--- a/polygerrit-ui/app/models/views/search_test.ts
+++ b/polygerrit-ui/app/models/views/search_test.ts
@@ -151,14 +151,27 @@
     test('userId', async () => {
       assert.isUndefined(userId);
 
+      // userId set when all owners are the same
       model.updateState({
-        query: 'owner: foo@bar',
+        query: 'owner:foo',
         changes: [
           {...createChange(), owner: {email: 'foo@bar' as EmailAddress}},
+          {...createChange(), owner: {email: 'foo@bar' as EmailAddress}},
         ],
       });
       assert.equal(userId, 'foo@bar' as EmailAddress);
 
+      // userId not set when multiple owners exist
+      model.updateState({
+        query: 'owner:foo',
+        changes: [
+          {...createChange(), owner: {email: 'foo@bar' as EmailAddress}},
+          {...createChange(), owner: {email: 'foo@foo' as EmailAddress}},
+        ],
+      });
+      assert.isUndefined(userId);
+
+      // userId not set when query is not about owner
       model.updateState({
         query: 'foo bar baz',
         changes: [
@@ -166,12 +179,6 @@
         ],
       });
       assert.isUndefined(userId);
-
-      model.updateState({
-        query: 'owner: foo@bar',
-        changes: [{...createChange(), owner: {}}],
-      });
-      assert.isUndefined(userId);
     });
 
     test('repo', async () => {