Fix selecting a profile ticking every M365-only and GWS-only user

_applyPendingProfileUsers() set u.selected = matches(u), where matches()
was `wanted.has(u.id) || (u.googleEmail && ...)`. For users without a
googleEmail (every M365-only and Google-only user) that evaluates to
undefined, not false — and both renderAccountList() and getSelectedUsers()
treat anything other than false as selected. So applying a profile ticked,
and would have scanned, all of those users in addition to the profile's own.

Coerce the googleEmail branch to a boolean.

Reproduced against a copy of real data: a 1-account profile ticked 56
(37 M365-only + 18 GWS-only extras); after the fix it ticks 1, and every
profile ticks only its own stored accounts.

Regression from bbe9c62 (released in 1.7.10).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
StyxX65andClaude Opus 5.5 committed 2026-09-28 10:15:36 +02:00
1 parent 5df151724a
commit 37c9cbfd2c
1 file changed
+4 -1
+4 -1
View File
@@ -238,7 +238,10 @@ function _applyPendingProfileUsers() {
if (!ids || !ids.length || !S._allUsers.length) return; if (!ids || !ids.length || !S._allUsers.length) return;
const wanted = new Set(ids); const wanted = new Set(ids);
// A saved google:<email> may since have merged onto an M365 user (platform 'both') // A saved google:<email> may since have merged onto an M365 user (platform 'both')
const matches = u => wanted.has(u.id) || (u.googleEmail && wanted.has('google:' + u.googleEmail)); // Must return a real boolean: the sidebar and getSelectedUsers() treat any
// selected value other than `false` as ticked, so an `undefined` here (users
// without googleEmail) ticked — and scanned — every M365-only/GWS-only user.
const matches = u => wanted.has(u.id) || !!(u.googleEmail && wanted.has('google:' + u.googleEmail));
S._allUsers.forEach(u => { u.selected = matches(u); }); S._allUsers.forEach(u => { u.selected = matches(u); });
renderAccountList(); renderAccountList();
const found = S._allUsers.filter(matches).length; const found = S._allUsers.filter(matches).length;