Skip to content

[Due for payment 2026-08-07] [$250] Workspace - Workspace avatar changes to user avatar after changing user avatar #95854

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.4.33-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/64161018/folder/13177080/41237930/1558638958?q=avatar&issue_type=jira&sort=-identifier
Email or phone of affected tester (no customers): sjdoijnsodijiosjdioso@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.5 / Chrome
App Component: User Settings

Action Performed:

  1. Go to staging.new.expensify.com
  2. Create a workspace.
  3. Go to Account > Profile.
  4. Click avatar.
  5. Click Upload photo.
  6. Upload a photo.
  7. Go to workspace chat.

Expected Result:

Workspace avatar will not change after changing user avatar.

Actual Result:

Workspace avatar changes to user avatar after changing user avatar.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome Safari

Screenshots/Videos

Bug7204917_1783703707985.5.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Svetlana Lazutkina
Bug ID: 7204917

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 10, 2026
  2. applause-bot commented on Jul 10, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/b7ad7216a76852328f7fbf8dd2e9e3b116607c8e35a137958d9a442766925469

  3. MelvinBot commented on Jul 10, 2026

    @MelvinBot
    Contributor

    Proposal

    ⚠️ Medium confidence — the mechanism is unambiguous in code, but whether this is a bug or working‑as‑designed is a product call (see the note at the end).

    Root Cause

    The workspace chat (policy expense chat) avatar is a two‑part avatar: a primary workspace icon plus an owner/member subscript. The primary workspace image is not affected by a user avatar change — for a freshly created workspace avatarURL is empty, so the primary is the deterministic name‑derived default building SVG. What actually changes is the subscript, which is the owner's personal avatar. Since the reporter created the workspace, they are the owner, so the subscript is their avatar — and it updates the moment they upload a new profile photo.

    So there is no state leak — personal and workspace avatars are separate. The perceived "workspace avatar changed" is the owner subscript re‑rendering with the new photo.

    Investigation details & data flow
    1. Create workspace → optimistic policy expense chat with ownerAccountID = currentUserAccountID, empty avatarURL/policyAvatar (buildOptimisticWorkspaceChats, ReportUtils.ts:8632; new‑policy default avatarURL: '' at Policy.ts:462).
    2. Chat renders via getIcons → getIconsForPolicyExpenseChat → [default building icon, owner subscript = current user].
    3. User uploads profile photo → updateAvatar merges into PERSONAL_DETAILS_LIST[accountID].avatar only (no policy write).
    4. Onyx change re‑renders the chat → the subscript re‑reads personalDetails[ownerAccountID].avatar → shows the new photo.

    Alternatives considered: a backend leak writing the user avatar into the policy's avatarURL was ruled out on the client side — updateAvatar never touches any COLLECTION.POLICY key, and the workspace‑icon read path never reads personal details. The change is entirely explained by the client‑side subscript logic above.

    Proposed Change (if this is deemed a bug)

    If the intent is that a workspace chat's avatar must not track the owner's personal photo, the change belongs at the subscript resolution in getIconsForPolicyExpenseChat (ReportUtils.ts:3858) — e.g. stop using the owner's live personal avatar as the workspace‑chat subscript. This needs a product decision first, because showing the member as the subscript on a policy expense chat is the current intended design.

    ⚠️ Product question for the team: For the workspace chat, should the subscript continue to show the owner's (live) personal avatar? If yes, this is working‑as‑designed and the report should be closed as WAI. If no, the fix is scoped to the single subscript line above.


    Related (not a duplicate): Expensify/App#93083 (Avatars: Default to Letters, recently closed) touched default‑avatar rendering.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/95854) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 10, 2026
  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 10, 2026
  6. MobileMage commented on Jul 10, 2026

    @MobileMage
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-07-10 17:40:08 UTC.

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When a workspace is created without uploading a workspace avatar, changing the user's own account avatar (Account > Profile > Upload photo) makes the workspace's avatar in the workspace chat change to the new personal photo. The expected behavior is that the workspace keeps its stable default avatar and does not track the user's personal avatar.

    What is the root cause of that problem?

    PR #93926 moved avatar cropping from a per-component modal to a shared crop screen that communicates through two global Onyx singletons, AVATAR_CROP_DRAFT and AVATAR_CROP_RESULT (src/ONYXKEYS.ts L103/L106), paired with a random token. When a picker opens the cropper, useAvatarCrop stores the token in its own tokenRef and persists a draft whose openerKey is the globally focused route:

    https://github.com/Expensify/App/blob/main/src/hooks/useAvatarCrop.ts#L43-L57

    The hook also has a re-adoption effect meant to recover a draft orphaned by a page refresh (L63-L83). That effect runs in every mounted instance of the hook whenever the draft changes, and its only ownership test compares two global values: the currently focused path (minus the crop suffix) against draft.openerKey (L76-L80). Nothing in the check identifies which picker actually opened the crop, so every mounted instance with an empty tokenRef adopts the token.

    The repro wires this up exactly. Creating a workspace lands on the workspace split navigator whose default central screen is WorkspaceOverviewPage (WorkspaceSplitNavigator.tsx L57), which mounts its own AvatarWithImagePicker and therefore its own useAvatarCrop instance (WorkspaceOverviewPage.tsx L525, AvatarWithImagePicker.tsx L120). Navigating to Account > Profile pushes the settings navigator on top, but the workspace screen is not frozen: freezeNonTopScreens is only enabled inside split navigators (createSplitNavigator/index.tsx L48), the Overview page remains the top central screen of its own split, and the root stack applies no freezing at all. The background workspace picker keeps reacting to Onyx. When the profile avatar form opens the cropper (useProfileAvatarForm.ts L51), the workspace instance's adoption effect sees the new draft, the focused-route comparison passes (it is a global fact, identical for every instance), and it silently adopts the profile crop's token.

    On crop save, AvatarCropPage writes the result under that token (AvatarCropPage.tsx L53-L56) and the consume effect (useAvatarCrop.ts L85-L94) fires in both instances. The profile form merely stages the image for a later Save, but the workspace picker's onCropped immediately calls updateWorkspaceAvatar(policyID, policy.avatarURL, file) (WorkspaceOverviewPage.tsx L544-L548), which optimistically sets policy.avatarURL and sends UpdateWorkspaceAvatar to the server (Policy.ts L1779-L1822). The user's cropped profile photo is genuinely persisted as the workspace avatar. That is why the change survives refresh and shows in the workspace chat, where getWorkspaceIcon (ReportUtils.ts L3445-L3452) is faithfully rendering the now-corrupted policy.avatarURL.

    Timing confirms the regression: the #93926 merge is an ancestor of the 9.4.29-1 version bump and therefore present in the reported 9.4.33-0, and the issue was filed as an exploratory regression two days after that PR shipped.

    What changes do you think we should make in order to solve the problem?

    Give each crop a stable identity for what avatar is being edited, and only let the instance editing that same target adopt the draft:

    1. useAvatarCrop accepts a targetKey: string param; openCropper writes it into the draft (extend SetAvatarCropDraftParams in src/libs/actions/AvatarCrop.ts and AvatarCropDraft in src/types/onyx/AvatarCropDraft.ts).
    2. In the re-adoption effect, require the identity match before the existing route check:
    if (draft.targetKey !== targetKey) {
        return;
    }
    1. Wiring is nearly free: AvatarWithImagePicker already receives type and avatarID props and can derive targetKey as `${type}-${String(avatarID)}` (e.g. workspace-<policyID> from WorkspaceOverviewPage.tsx L533); the profile form passes a profile key (e.g. avatar-<accountID>). If a caller provides no key, fall back to today's route-only check so unkeyed callers degrade to current behavior rather than breaking.

    This shape is immune to the Onyx hydration race: the guard compares the draft against a stable value derived from props, so it does not matter when useOnyx delivers the draft. It also survives refresh by construction, because the key is recomputed from policyID/accountID on remount, so the true opener re-adopts exactly as the effect intends while background pickers (different targets) can never adopt. The existing openerKey focused-route check stays as a secondary guard. Two co-mounted instances with the same targetKey would both deliver, but same target means the same semantic update, so that is harmless.

    Tests: (a) two hooks with different target keys, draft written for A, only A's onCropped fires when the result lands; (b) refresh simulation, a fresh mount with a pre-existing draft whose targetKey matches re-adopts after isNavigationReady(); (c) flow regression, with a background workspace Overview mounted, a profile crop must not call updateWorkspaceAvatar and policy.avatarURL stays empty.

    What alternative solutions did you explore? (Optional)

    Snapshotting the live token at mount (via a hydration-safe read like useInitialOnyxValue) closes the refresh race but still lets a picker that first hydrates while a crop is live snapshot-and-adopt the live token. Capturing "my own route" at mount does not survive refresh, because during state reconstruction Navigation.getActiveRoute() returns the crop route for every remounting screen, so background pickers would capture the opener's route and still collide. A module-scoped "live token" flag also fixes the repro but adds shared mutable state that is awkward to reset and test. The target-key identity avoids all three holes.

    An earlier revision of this proposal read the symptom as a display-layer fallback in getWorkspaceIcon with backend-seeded avatarURL. The regression timing and the write path above rule that out: the avatar change is a real client-initiated UpdateWorkspaceAvatar persisted server-side, so any render-side guard would only mask corrupted data (and would break owners who deliberately use the same photo for profile and workspace).

  7. shivang-goliyan commented on Jul 10, 2026

    @shivang-goliyan
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-07-13 22:27:19 UTC.

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Right after creating a workspace, if you go to Account > Profile and change your personal avatar, the workspace's avatar changes to that same photo. The workspace should keep its own avatar and ignore edits to your personal one.

    What is the root cause of that problem?

    This is a real persisted write, not a render artifact. When you save the profile crop, a background updateWorkspaceAvatar API call actually fires and writes policy.avatarURL to your personal photo.

    The collision lives in the re-adoption effect in src/hooks/useAvatarCrop.ts:63-83. That effect is instance-blind. Its only ownership test (lines 76-78) compares the global focused route Navigation.getActiveRoute() (with the /avatar-crop suffix stripped) against draft.openerKey. Both are the same global string for every mounted instance of the hook — nothing identifies which picker actually opened the crop. Its deps are [draft?.token, draft?.openerKey], so it runs the moment the profile picker writes AVATAR_CROP_DRAFT, in the normal flow, not just on refresh.

    Trace it against the exact repro steps:

    1. Repro step 2 ("Create a workspace") lands you on WorkspaceOverviewPage, which mounts its own useAvatarCrop with tokenRef = null (src/pages/workspace/WorkspaceOverviewPage.tsx:540-545 wires its picker's onImageSelected to updateWorkspaceAvatar(policyID, policy.avatarURL, file)).
    2. You open Account > Profile and crop a new photo. The profile picker writes AVATAR_CROP_DRAFT{token, openerKey: <profile route>} and navigates to <profile route>/avatar-crop.
    3. The still-mounted workspace instance's effect runs: its tokenRef is null, the focused path minus suffix is <profile route>, which equals draft.openerKey — so it adopts the profile token as its own.
    4. On save, AVATAR_CROP_RESULT carries that token, which now matches tokenRef in both the profile instance and the workspace instance (useAvatarCrop.ts:85-94). Both onCropped callbacks fire. AvatarWithImagePicker.tsx:120 wires onCropped: onImageSelected, so the workspace instance calls updateWorkspaceAvatar with your personal photo.

    This also explains why "Create a workspace" is a required repro step: you have to be sitting on a page with a live, mounted workspace picker for the two instances to collide.

    What changes do you think we should make in order to solve the problem?

    Gate re-adoption to the instance that actually owns the draft. The check at useAvatarCrop.ts:76-78 needs an instance-specific identity instead of the shared global route.

    There is a hazard here that decides whether the fix is correct, and it rules out the obvious implementation. The effect exists to recover an orphaned crop after a cold refresh, so the guard cannot simply snapshot the draft at mount: useOnyx hydrates asynchronously, so on a cold web refresh draft is undefined on the first render. A naive useRef(draft?.token) captures null, and then rejects the very orphaned token it was meant to re-adopt — silently breaking refresh recovery while appearing to fix the reported bug.

    So the guard has to be hydration-aware. Use the existing useInitialOnyxValue helper to snapshot the draft at Onyx loaded rather than at first render, and compare re-adoption against that instance-local snapshot. Cold-refresh recovery keeps working, and the workspace instance no longer matches the profile token, so the stray updateWorkspaceAvatar never fires.

    Add a test that mounts two AvatarWithImagePicker instances (workspace + profile), triggers a profile crop, and asserts updateWorkspaceAvatar is not called — that is the exact path that shipped broken. A second test should cold-mount with Onyx unhydrated and assert the orphaned draft is still re-adopted, which is the case a first-render ref snapshot regresses.

    What alternative solutions did you explore? (Optional)

    Render-side fixes do not work here, because the personal photo is genuinely persisted onto policy.avatarURL — the leak survives a reload:

    • Removing the owner subscript from getIconsForPolicyExpenseChat, or clearing the getWorkspaceIcon module cache, only changes what is drawn; the bad write still lands.
    • The report.policyAvatar fallback is read-only: grep policyAvatar src/libs/actions/ returns nothing, so it is backend-denormalized and only consulted while the policy is still loading. Any issue there is a transient loading-window bug and a backend fix, out of App scope.

    The subscript theory also fails the video: the final frame shows the large primary square icon become the photo, and a subscript-only change (icons[1]) cannot move icons[0]. Those theories would also fire for any no-custom-avatar workspace on any avatar change, with no need to have just created one — which is not what the report describes.

  8. ahmdshrif commented on Jul 10, 2026

    @ahmdshrif
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-07-10 17:47:43 UTC.

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    After the user uploads a new profile photo (Account > Profile > avatar > Upload photo), the workspace avatar of a workspace they created earlier changes to that same photo. The wrong avatar then shows in the workspace chat.

    What is the root cause of that problem?

    The workspace avatar is not just rendered wrong — it is really uploaded to the workspace. The new avatar-crop flow delivers the cropped profile photo to the workspace avatar picker too, which calls UpdateWorkspaceAvatar.

    Evidence chain:

    1. PR #93926 (merged 2026-07-08, in 9.4.33) migrated AvatarCropModal from a per-component modal — whose save callback could only reach its own opener — to a navigation screen that hands the image back through two global Onyx keys, AVATAR_CROP_DRAFT / AVATAR_CROP_RESULT, paired with a token:

      App/src/ONYXKEYS.ts

      Lines 103 to 106 in 5ee0283

      AVATAR_CROP_DRAFT: 'avatarCropDraft',
      /** Cropped image the avatar crop screen writes back for its opener */
      AVATAR_CROP_RESULT: 'avatarCropResult',

    2. When the profile flow opens the cropper, openCropper stores a draft {token, openerKey} where openerKey is the focused route:

      const openCropper = (image: FileObject) => {
      const token = rand64();
      tokenRef.current = token;
      // Capture the opener's route now: serialization below is async (slow on web) and the active
      // route can change if the user navigates away before it resolves.
      const baseRoute = Navigation.getActiveRoute();
      setAvatarCropDraft({token, image, openerKey: getOpenerKey(baseRoute), maskType, buttonLabelKey}).then(() => {
      // Abort if the opener unmounted or started a newer crop while serializing — navigating now
      // would yank the user back or open the crop screen under a disallowed entry screen.
      if (tokenRef.current !== token) {
      return;
      }
      // Append `/avatar-crop` to the opener's route so the crop screen opens under its context.
      Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.AVATAR_CROP.path, baseRoute));
      });

    3. Structural cause: the "re-adopt after refresh" effect in useAvatarCrop is instance-blind. Every mounted instance of the hook subscribes to the same global draft key, and the only guard compares two global strings — Navigation.getActiveRoute() vs draft.openerKey — which are identical for every instance. Nothing identifies which picker actually opened the crop, so every mounted picker with no token of its own adopts the profile crop's token:

      useEffect(() => {
      if (tokenRef.current || !draft?.token || !draft.openerKey) {
      return;
      }
      const draftToken = draft.token;
      const draftOpenerKey = draft.openerKey;
      // On a cold web refresh this effect can fire before the navigation container is initialized,
      // when getActiveRoute() still returns ''. Wait for nav to be ready so the opener-route
      // comparison uses the real focused path; otherwise adoption would silently never happen.
      Navigation.isNavigationReady().then(() => {
      if (tokenRef.current) {
      return;
      }
      const focusedPath = splitPathAndQuery(Navigation.getActiveRoute()).at(0) ?? '';
      const openerPath = focusedPath.endsWith(CROP_SUFFIX) ? focusedPath.slice(0, -CROP_SUFFIX.length) : focusedPath;
      if (openerPath !== draftOpenerKey) {
      return;
      }
      tokenRef.current = draftToken;
      });
      }, [draft?.token, draft?.openerKey]);

    4. This is why repro step 2 ("Create a workspace") is required: creating a workspace lands on workspace settings, whose Overview page renders its own AvatarWithImagePicker (

      <AvatarWithImagePicker
      ), and each AvatarWithImagePicker mounts its own useAvatarCrop (
      const {openCropper} = useAvatarCrop({maskType: editorMaskImage ? 'square' : undefined, onCropped: onImageSelected});
      ). Navigating to Account > Profile pushes settings on top; the workspace screen stays mounted and reactive underneath, so its effect runs and adopts the token.

    5. On save, the crop screen writes the result under the same token (

      setAvatarCropResult({token: draft.token, image}).then(() => {
      Navigation.goBack();
      });
      ). The consume effect (
      useEffect(() => {
      if (!result || result.token !== tokenRef.current) {
      return;
      }
      tokenRef.current = null;
      const image = buildFileFromAvatarCropResult(result);
      // Clear only the result; the draft is owned (and cleared) by the crop screen on unmount.
      clearAvatarCropResult();
      onCropped(image);
      }, [result, onCropped]);
      ) then matches in both instances: the profile form stores the image for updateAvatar, and the workspace picker's onCropped immediately calls updateWorkspaceAvatar(policyID, policy.avatarURL, file) (
      onImageSelected={(file) => {
      if (!policyID) {
      return;
      }
      updateWorkspaceAvatar(policyID, policy.avatarURL, file as File);
      ) — a real API write.

    6. The workspace chat then correctly renders policy.avatarURL — now the user's photo — as the workspace icon via getWorkspaceIcon:

      App/src/libs/ReportUtils.ts

      Lines 3445 to 3452 in 5ee0283

      function getWorkspaceIcon(report: OnyxInputOrEntry<Report>, policy?: OnyxInputOrEntry<Policy>): Icon {
      const workspaceName = getPolicyName({report, policy});
      const cacheKey = report?.policyID ?? workspaceName;
      const iconFromCache = workSpaceIconsCache.get(cacheKey);
      const reportPolicy = policy ?? allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`];
      const policyAvatarURL = reportPolicy ? reportPolicy?.avatarURL : report?.policyAvatar;
      // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
      const policyExpenseChatAvatarSource = policyAvatarURL || getDefaultWorkspaceAvatar(workspaceName);

    This explains every detail: why the workspace must be created first, why the change survives navigation/refresh (server-side upload), and why it reproduces on web (background stack screens stay mounted).

    All affected paths — any pair of simultaneously mounted pickers collides, in either direction: workspace avatar (WorkspaceOverviewPage), new-workspace form (WorkspaceConfirmationForm), WorkspaceDuplicateForm, group-chat avatar (NewChatConfirmPage, DynamicReportDetailsPage), agent avatar (EditAgentAvatarPage), and profile (useProfileAvatarForm.ts#L51). One shared-hook fix covers all of them.

    What changes do you think we should make in order to solve the problem?

    Fix inside useAvatarCrop only. Adoption exists solely to recover a draft orphaned by a page refresh — in a live session the opener already holds the token in its tokenRef. So record live ownership at module scope and refuse adoption of an owned token:

    // useAvatarCrop.ts
    let sessionOwnedToken: string | null = null; // token held by a live opener
    
    const openCropper = (image: FileObject) => {
        const token = rand64();
        tokenRef.current = token;
        sessionOwnedToken = token;
        // ...unchanged
    };
    
    // re-adoption effect, first guard:
    if (tokenRef.current || !draft?.token || !draft.openerKey || draft.token === sessionOwnedToken) {
        return;
    }

    openCropper sets the flag synchronously before the draft is written, so no background instance can ever adopt a live token. After a refresh the module resets to null, the draft is genuinely orphaned, and only the URL-derived stack is remounted, so the existing openerKey route check re-ties the draft to the true opener exactly as designed. Regression safety in one sentence: the token/result flow, refresh recovery, and all opener callbacks are unchanged — the guard only blocks adoption while the real opener is still alive. I'd add a unit test covering "second mounted hook must not adopt a live draft".

    Why the obvious spot-fix fails: gating adoption on useIsFocused() breaks the one scenario adoption exists for — after a mid-crop refresh the opener sits under the crop screen and is never focused, and by the time focus returns, the crop screen's unmount cleanup has already cleared the draft (AvatarCropPage.tsx#L39), so refresh recovery silently dies. Likewise, capturing "my own route" in a ref at mount doesn't work: during post-refresh state reconstruction Navigation.getActiveRoute() returns the crop route for every remounting screen, so the true opener cannot learn its own path that way.

    What alternative solutions did you explore? (Optional)

    1. Per-instance route identity — compare draft.openerKey against the instance's own screen path (useRoute() + linking-config path serialization) instead of the global focused route. Also correct, but requires a reliable per-screen route→URL serialization and extra plumbing; the one-variable ownership guard achieves the same with zero added per-render work.
    2. useIsFocused() gate on adoption/consumption — incomplete, as shown above (kills refresh recovery, races the draft cleanup).
    3. Revert #93926 — not appropriate; the modal→screen migration was intentional (navigable/deep-linkable crop screen). The fix should preserve it, and the guard above does.
  9. aswin-s commented on Jul 10, 2026

    @aswin-s
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On Web, after a user creates a workspace and then uploads a new personal profile photo (Account > Profile > avatar > Upload photo), navigating to the workspace chat shows the newly-uploaded personal photo in the workspace chat's avatar area (as the subscript of the SubscriptAvatar). Expected: the workspace chat's avatar display should be driven entirely by the workspace's own avatar data and should never change in response to personal profile photo changes.

    What is the root cause of that problem?

    getIconsForPolicyExpenseChat at src/libs/ReportUtils.ts:3848 unconditionally builds a memberIcon via getParticipantIcon(report.ownerAccountID, personalDetails, translate, true) (line 3858) and returns it as icons[1]. getParticipantIcon at line 3696 reads source: details?.avatar ?? getDefaultAvatarURL({accountID}) — directly from live Onyx personalDetails. For a workspace the current user just created, ownerAccountID equals the current user's account ID, so icons[1].source is literally the current user's live personal avatar.

    When updateAvatar (src/libs/actions/PersonalDetails.ts:353) writes the new photo to ONYXKEYS.PERSONAL_DETAILS_LIST[currentUserAccountID].avatar, Onyx triggers a re-render of every consumer of personalDetails. getIconsForPolicyExpenseChat re-runs, getParticipantIcon reads the new URL, and icons[1].source flips to the uploaded personal photo. The workspace chat's SubscriptAvatar renders this as its subscript — the user perceives the workspace avatar as having changed to their personal photo.

    Note: icons[0] (workspaceIcon) is built from policy.avatarURL ?? getDefaultWorkspaceAvatar(workspaceName) and is not affected by personal detail changes. The visual artifact is on icons[1].

    What changes do you think we should make in order to solve the problem?

    The working analog is getIconsForPolicyRoom (src/libs/ReportUtils.ts:3829) and getIconsForUserCreatedPolicyRoom (line 3962): both return [workspaceIcon] only, with no member icon derived from personal details. getIconsForPolicyExpenseChat should follow the same pattern.

    Change 1 — src/libs/ReportUtils.ts:3848-3860 (getIconsForPolicyExpenseChat):

    Remove the memberIcon derivation entirely and return only [workspaceIcon]:

    function getIconsForPolicyExpenseChat(
        report: OnyxInputOrEntry<Report>,
        personalDetails: OnyxInputOrEntry<PersonalDetailsList>,
        policy: OnyxInputOrEntry<Policy>,
        translate: LocalizedTranslate,
    ): Icon[] {
        if (!report) {
            return [];
        }
        return [getWorkspaceIcon(report, policy)];
    }

    The personalDetails and translate parameters become unused and can be removed from the signature once callers at getIcons (line 4027) are updated to match.

    Change 2 — Add a regression test in tests/unit/ReportUtilsTest.ts:

    Create a policyExpenseChat report with ownerAccountID = currentUserAccountID. Assert that getIcons(report, ...) returns exactly one icon whose source matches the workspace avatar (not personalDetails[currentUserAccountID].avatar). Then mutate personalDetails[currentUserAccountID].avatar to a new URL and assert getIcons(report, ...)[0].source is unchanged.

    Why getIconsForExpenseReport does NOT need the same fix

    getIconsForExpenseReport (src/libs/ReportUtils.ts:3865) returns [memberIcon, workspaceIcon] — memberIcon is icons[0] (the primary avatar). In an expense report, the submitter's personal avatar IS the correct primary avatar to display; it is expected to update when personal details change. No change is needed there.

    What alternative solutions did you explore?

    • Condition the fix on policy.avatarURL === undefined: Rejected — even workspaces with a custom avatarURL still emit a memberIcon from live personal details in the current code, so the bug would persist for those workspaces. The fix must be unconditional.
    • Fall back to the workspace default inside getParticipantIcon when called from a policy-expense-chat context: Rejected — this adds a context signal parameter to a general-purpose helper, increasing coupling. The clean fix is at the call site (getIconsForPolicyExpenseChat) following the established pattern of sibling functions.
  10. KJ21-ENG commented on Jul 10, 2026

    @KJ21-ENG
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-07-10 17:52:51 UTC.

    Proposal

    What is the root cause of that problem?

    Saving a new profile picture only calls the profile avatar save path and updateAvatar(), whose optimistic/success/failure data is scoped to PERSONAL_DETAILS_LIST. That makes the personal avatar upload the trigger, not the place where workspace avatar data should be changed.

    const save = () => {
    isSavingRef.current = true;
    const previousAvatar = {
    avatar: currentUserPersonalDetails?.avatar,
    avatarThumbnail: currentUserPersonalDetails?.avatarThumbnail,
    accountID: currentUserPersonalDetails?.accountID,
    };
    if (imageData.file) {
    updateAvatar(imageData.file, previousAvatar);
    setImageData({...EMPTY_FILE});
    Navigation.dismissModal();
    return;
    }

    function updateAvatar(
    file: File | CustomRNImageManipulatorResult | DefaultAvatarResult,
    currentUserPersonalDetails: Pick<CurrentUserPersonalDetails, 'avatarThumbnail' | 'avatar' | 'accountID'>,
    ) {
    if (!currentUserPersonalDetails.accountID) {
    return;
    }
    const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.PERSONAL_DETAILS_LIST>> = [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: ONYXKEYS.PERSONAL_DETAILS_LIST,
    value: {
    [currentUserPersonalDetails.accountID]: {
    avatar: file.uri,
    avatarThumbnail: file.uri,
    originalFileName: file.name,
    errorFields: {
    avatar: null,
    },
    pendingFields: {
    avatar: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
    originalFileName: null,
    },
    fallbackIcon: file.uri,
    },
    },
    },
    ];
    const successData: Array<OnyxUpdate<typeof ONYXKEYS.PERSONAL_DETAILS_LIST>> = [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: ONYXKEYS.PERSONAL_DETAILS_LIST,
    value: {
    [currentUserPersonalDetails.accountID]: {
    pendingFields: {
    avatar: null,
    },
    },
    },
    },
    ];
    const failureData: Array<OnyxUpdate<typeof ONYXKEYS.PERSONAL_DETAILS_LIST>> = [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: ONYXKEYS.PERSONAL_DETAILS_LIST,
    value: {
    [currentUserPersonalDetails.accountID]: {
    avatar: currentUserPersonalDetails?.avatar,
    avatarThumbnail: currentUserPersonalDetails?.avatarThumbnail ?? currentUserPersonalDetails?.avatar,
    pendingFields: {
    avatar: null,
    },
    } as OnyxEntry<Partial<PersonalDetails>>,
    },
    },
    ];
    const parameters: UpdateUserAvatarParams = isDefaultAvatarResult(file) ? {customExpensifyAvatarID: file.customExpensifyAvatarID} : {file};
    API.write(WRITE_COMMANDS.UPDATE_USER_AVATAR, parameters, {optimisticData, successData, failureData});

    The workspace chat avatar shown in the bug comes from the policy expense chat icon path: getIconsForPolicyExpenseChat() returns the workspace icon first and the report owner/member icon second, and ReportActionAvatars renders those icons in the header/list avatar UI.

    App/src/libs/ReportUtils.ts

    Lines 3848 to 3859 in 5ee0283

    function getIconsForPolicyExpenseChat(
    report: OnyxInputOrEntry<Report>,
    personalDetails: OnyxInputOrEntry<PersonalDetailsList>,
    policy: OnyxInputOrEntry<Policy>,
    translate: LocalizedTranslate,
    ): Icon[] {
    if (!report) {
    return [];
    }
    const workspaceIcon = getWorkspaceIcon(report, policy);
    const memberIcon = getParticipantIcon(report?.ownerAccountID, personalDetails, translate, true);
    return [workspaceIcon, memberIcon];

    const [primaryAvatar, secondaryAvatar] = icons;
    if (avatarType === CONST.REPORT_ACTION_AVATARS.TYPE.SUBSCRIPT && (!!secondaryAvatar?.name || !!subscriptCardFeed)) {
    return (
    <ReportActionAvatar.Subscript
    primaryAvatar={primaryAvatar}
    secondaryAvatar={secondaryAvatar}
    size={size}
    shouldShowTooltip={shouldShowTooltip}
    noRightMarginOnContainer={noRightMarginOnSubscriptContainer}
    subscriptAvatarBorderColor={subscriptAvatarBorderColor}
    subscriptCardFeed={subscriptCardFeed}
    subscriptCardFeedIconSize={subscriptCardFeedIconSize}
    useProfileNavigationWrapper={useProfileNavigationWrapper}
    fallbackDisplayName={fallbackDisplayName}
    reportID={reportID}
    />
    );
    }
    if (avatarType === CONST.REPORT_ACTION_AVATARS.TYPE.MULTIPLE_HORIZONTAL) {
    return (
    <ReportActionAvatar.Multiple.Horizontal
    {...(isHorizontalStackingAnObject ? horizontalStacking : {})}
    size={size}
    icons={icons}
    isInReportAction={isInReportAction}
    shouldShowTooltip={shouldShowTooltip}
    useProfileNavigationWrapper={useProfileNavigationWrapper}
    fallbackDisplayName={fallbackDisplayName}
    reportID={reportID}
    />
    );
    }
    if (avatarType === CONST.REPORT_ACTION_AVATARS.TYPE.MULTIPLE_DIAGONAL && !!secondaryAvatar?.name) {
    return (
    <ReportActionAvatar.Multiple.Diagonal
    shouldShowTooltip={shouldShowTooltip}
    size={size}
    icons={icons}
    isInReportAction={isInReportAction}
    useMidSubscriptSize={useMidSubscriptSizeForMultipleAvatars}
    secondaryAvatarContainerStyle={secondaryAvatarContainerStyle}
    isHovered={isHovered}
    fallbackDisplayName={fallbackDisplayName}
    useProfileNavigationWrapper={useProfileNavigationWrapper}
    reportID={reportID}
    />

    getWorkspaceIcon() caches workspace icons by policy ID/name. It resolves the source from policy.avatarURL when policy data exists, otherwise from report.policyAvatar, otherwise from getDefaultWorkspaceAvatar(workspaceName). The cache then returns the old icon whenever the current policyAvatarURL is undefined, even if policy data is now available and the correct resolved source is the default workspace avatar. So if a temporary report-level workspace avatar fallback is the user's newly uploaded avatar, that source can be cached and kept for the workspace after the policy resolves with no custom avatarURL.

    App/src/libs/ReportUtils.ts

    Lines 3440 to 3468 in 5ee0283

    const workSpaceIconsCache = new Map<string, {name: string; icon: Icon}>();
    /**
    * Given a report, return the associated workspace icon.
    */
    function getWorkspaceIcon(report: OnyxInputOrEntry<Report>, policy?: OnyxInputOrEntry<Policy>): Icon {
    const workspaceName = getPolicyName({report, policy});
    const cacheKey = report?.policyID ?? workspaceName;
    const iconFromCache = workSpaceIconsCache.get(cacheKey);
    const reportPolicy = policy ?? allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`];
    const policyAvatarURL = reportPolicy ? reportPolicy?.avatarURL : report?.policyAvatar;
    // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
    const policyExpenseChatAvatarSource = policyAvatarURL || getDefaultWorkspaceAvatar(workspaceName);
    const isSameAvatarURL = iconFromCache?.icon?.source === policyExpenseChatAvatarSource;
    const hasWorkSpaceNameChanged = iconFromCache?.name !== workspaceName;
    if (iconFromCache && (isSameAvatarURL || policyAvatarURL === undefined) && !hasWorkSpaceNameChanged) {
    return iconFromCache.icon;
    }
    const workspaceIcon: Icon = {
    source: policyExpenseChatAvatarSource || defaultWorkspaceAvatars.WorkspaceBuilding,
    type: CONST.ICON_TYPE_WORKSPACE,
    name: workspaceName,
    id: report?.policyID,
    };
    workSpaceIconsCache.set(cacheKey, {name: workspaceName, icon: workspaceIcon});
    return workspaceIcon;

    What changes do you think we should make in order to solve the problem?

    Update getWorkspaceIcon() so the cache is only reused when it matches the currently resolved workspace source, except for the existing "policy data is unavailable" fallback case.

    Concretely, split source resolution into two states: whether a policy object was found, and which workspace source should be used. If a policy object exists but policy.avatarURL is empty, resolve to getDefaultWorkspaceAvatar(workspaceName) and refresh the cache with that default icon. Only use report.policyAvatar while policy data is unavailable, and only keep a cached icon for an undefined report fallback when policy data is still unavailable. This preserves the report-level fallback for loading/offline cases, but prevents a cached user-avatar fallback from surviving after the app knows the workspace has no custom avatar.

    App/src/libs/ReportUtils.ts

    Lines 3445 to 3468 in 5ee0283

    function getWorkspaceIcon(report: OnyxInputOrEntry<Report>, policy?: OnyxInputOrEntry<Policy>): Icon {
    const workspaceName = getPolicyName({report, policy});
    const cacheKey = report?.policyID ?? workspaceName;
    const iconFromCache = workSpaceIconsCache.get(cacheKey);
    const reportPolicy = policy ?? allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`];
    const policyAvatarURL = reportPolicy ? reportPolicy?.avatarURL : report?.policyAvatar;
    // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
    const policyExpenseChatAvatarSource = policyAvatarURL || getDefaultWorkspaceAvatar(workspaceName);
    const isSameAvatarURL = iconFromCache?.icon?.source === policyExpenseChatAvatarSource;
    const hasWorkSpaceNameChanged = iconFromCache?.name !== workspaceName;
    if (iconFromCache && (isSameAvatarURL || policyAvatarURL === undefined) && !hasWorkSpaceNameChanged) {
    return iconFromCache.icon;
    }
    const workspaceIcon: Icon = {
    source: policyExpenseChatAvatarSource || defaultWorkspaceAvatars.WorkspaceBuilding,
    type: CONST.ICON_TYPE_WORKSPACE,
    name: workspaceName,
    id: report?.policyID,
    };
    workSpaceIconsCache.set(cacheKey, {name: workspaceName, icon: workspaceIcon});
    return workspaceIcon;

    Because policy expense chat avatars, report avatar preview, workspace rooms, expense reports, invoice icons, and workspace search cells all rely on getWorkspaceIcon(), fixing the helper keeps the rendering consistent instead of patching only the workspace chat screen.

    App/src/libs/ReportUtils.ts

    Lines 3828 to 3859 in 5ee0283

    */
    function getIconsForPolicyRoom(
    report: OnyxInputOrEntry<Report>,
    personalDetails: OnyxInputOrEntry<PersonalDetailsList>,
    policy: OnyxInputOrEntry<Policy>,
    invoiceReceiverPolicy: OnyxInputOrEntry<Policy>,
    ): Icon[] {
    if (!report) {
    return [];
    }
    const icons = [getWorkspaceIcon(report, policy)];
    if (report && isInvoiceRoom(report)) {
    icons.push(...getInvoiceReceiverIcons(report, personalDetails, invoiceReceiverPolicy));
    }
    return icons;
    }
    /**
    * Helper function to get the icons for a policy expense chat. Only to be used in getIcons().
    */
    function getIconsForPolicyExpenseChat(
    report: OnyxInputOrEntry<Report>,
    personalDetails: OnyxInputOrEntry<PersonalDetailsList>,
    policy: OnyxInputOrEntry<Policy>,
    translate: LocalizedTranslate,
    ): Icon[] {
    if (!report) {
    return [];
    }
    const workspaceIcon = getWorkspaceIcon(report, policy);
    const memberIcon = getParticipantIcon(report?.ownerAccountID, personalDetails, translate, true);
    return [workspaceIcon, memberIcon];

    Test coverage:

    • Add a unit test for getWorkspaceIcon() that first caches a report-level policyAvatar, then calls the helper with the same policy ID and a policy object whose avatarURL is empty; assert the returned source is getDefaultWorkspaceAvatar(workspaceName).
    • Add a companion test where policy data is unavailable and a real report.policyAvatar exists; assert the report fallback is still returned.
    • Add/update a regression test around profile avatar upload followed by opening the user's policy expense chat; assert a workspace with no custom avatar still shows the default workspace avatar while the member avatar shows the new user photo.

    What alternative solutions did you explore? (Optional)

    One alternative is to make updateAvatar() clear or rewrite policy expense chat avatar fields after a personal avatar upload. I would avoid that because the profile avatar action correctly only updates personal details, and coupling it to workspace reports would miss reports loaded later.

    Another alternative is to compare report.policyAvatar against the report owner's personal avatar and reject matching values. That is less precise because a workspace could intentionally use the same image as its owner, and it still would not address the stale cache condition. The shared helper should instead use policy data precedence and cache invalidation to decide the workspace source.

  11. godzillaxbox19982014-lgtm commented on Jul 10, 2026

    @godzillaxbox19982014-lgtm

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Workspace - Workspace avatar changes to user avatar after changing user avatar

    What is the root cause of that problem?

    I traced this to the path that handles workspace, avatar, change:

    What changes do you think we should make in order to solve the problem?

    • Change the issue-matching decision at src/pages/workspace/receiptPartners/ChangeReceiptBillingAccountPage.tsx:72 so the workspace, avatar, change repro state is represented before src/pages/media/AttachmentModalScreen/routes/WorkspaceAvatarModalContent.tsx:26 consumes it.
    • Keep the patch at this first decision/consumer boundary (move the rule into the shared selector/helper) instead of masking the downstream UI symptom.
    • Keep the change inside the Workspace, Policy, Categories, Tags, Rules surface and avoid changing account/admin permission surfaces, policy owner/current-user exceptions.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    1. Add or update a regression in tests/unit/Policy*.ts for the exact issue flow: Workspace - Workspace avatar changes to user avatar after changing user avatar.
    2. Cover the counter-case near src/pages/workspace/receiptPartners/ChangeReceiptBillingAccountPage.tsx:72 so valid existing workspace, avatar, change behavior still works.
    3. Manually repeat the issue steps after the patch and confirm the visible state/action is no longer stale.

    What alternative solutions did you explore? (Optional)

    • I would not add a broad new condition outside these referenced paths; the safer fix is to keep workspace, avatar, change consistent at the first read/write boundary shown above.
  12. melvin-bot commented on Jul 10, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @ZhenjaHorbach (External)

  13. 41 remaining items

  14. melvin-bot commented on Aug 5, 2026

    @melvin-bot

    @ZhenjaHorbach Eep! 4 days overdue now. Issues have feelings too...

  15. ZhenjaHorbach commented on Aug 6, 2026

    @ZhenjaHorbach
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

    https://github.com/Expensify/App/pull/93926/changes#r3726917521

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion:

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal

    Test:

    1. Open App
    2. Go to Account > Profile and note your current profile photo.
    3. Create a workspace (this lands on Workspace Overview, which mounts its own avatar picker) and note that its avatar is the default letter avatar.
    4. Without navigating away from the workspace, go to Account > Profile.
    5. Click the profile avatar, click Upload photo, choose a photo, and save it on the crop screen.
    6. Verify the profile avatar updates to the photo you uploaded.
    7. Go back to the workspace's Overview page and verify its avatar is unchanged (still the default letter avatar).
    8. Verify the workspace avatar is also unchanged in the workspace chat and in the workspace list.

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-2e0c-a673-6704-8f24106bec64
  16. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Aug 6, 2026
  17. melvin-bot commented on Aug 6, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  18. melvin-bot commented on Aug 6, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
  19. mallenexpensify commented on Aug 8, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @ahmdshrif paid $250 via Upwork
    Contributor+: @ZhenjaHorbach due $250 via NewDot

  20. garrettmknight commented on Aug 10, 2026

    @garrettmknight
    Contributor

    $250 approved for @ZhenjaHorbach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions