diff --git a/tdrive/backend/node/src/services/console/clients/remote.ts b/tdrive/backend/node/src/services/console/clients/remote.ts index 22c8ff2d..692eb440 100644 --- a/tdrive/backend/node/src/services/console/clients/remote.ts +++ b/tdrive/backend/node/src/services/console/clients/remote.ts @@ -214,8 +214,16 @@ export class ConsoleRemoteClient implements ConsoleServiceClient { await gr.services.companies.setUserRole(company.id, user.id, userRole); - await gr.services.users.save(user, { user: { id: user.id, server_request: true } }); - + // [Workavia] Removed an upstream `users.save(user, ...)` here that + // overwrote the user record after setUserRole (line above) had + // already fetched a fresh user, pushed the new companyId into + // user.cache.companies, and saved. Saving the stale local `user` + // object on top wiped cache.companies → the OpenSearch `user` index + // ended up with an empty `companies` field → frontend share-picker + // search returned zero results for same-Company users. Without this + // double-save, setUserRole's save is the last write and the index + // is correct. Surfacing this comment so it doesn't get reintroduced + // on rebase. return user; }