Skip to content

Chat - Custom avatar is not displayed on a group chat #85726

Closed

Description

@mitarachim

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: v9.3.40-0
Reproducible in staging?: Yes
Reproducible in production?: No
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/TR-10400/folder/13176684/41236576/1260624381?sort=%2Bstatus_id
Email or phone of affected tester (no customers): gocemate+b21549011@gmail.com
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Windows 10/Chrome
App Component: Chat Report View

Action Performed:

  1. Go to FAB> Start chat> Add members
  2. Click on avatar while creating and add a photo
  3. Save the process

Expected Result:

Avatar should be displayed

Actual Result:

Custom avatar is not displayed

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7106331_1773845859465.Recording__538.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @rinej

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    DeployBlockerIndicates it should block deploying the API
    on Mar 19, 2026
  2. melvin-bot commented on Mar 19, 2026

    @melvin-bot

    Triggered auto assignment to @arosiclair (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  3. melvin-bot commented on Mar 19, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  4. github-actions commented on Mar 19, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  5. MelvinBot commented on Mar 19, 2026

    @MelvinBot
    Contributor

    Proposal

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

    When creating a group chat via FAB > Start chat > Add members, if the user sets a custom avatar during creation, the avatar is not displayed after saving. This is reproducible in staging (v9.3.40-0) but not in production (v9.3.39-3), indicating a recent regression.

    What is the root cause of that problem?

    The most likely root cause is PR #85231 ("Fix - heic context lost"), which changed the web implementation of cropOrRotateImage from the deprecated manipulateAsync API to the new ImageManipulator.manipulate() chain API. This PR was merged on March 17 and is in staging but not yet in production — perfectly matching the bug's staging-only reproducibility.

    How the avatar flow works:

    1. User selects/crops an avatar image in AvatarWithImagePicker → AvatarCropModal calls cropOrRotateImage() (src/libs/cropOrRotateImage/index.ts) to produce a File object
    2. NewChatConfirmPage stores the File in component state (avatarFile) and the URI string in Onyx draft (avatarUri) (src/pages/NewChatConfirmPage.tsx:148-158)
    3. On "Start group", navigateToAndCreateGroupChat builds an optimistic report with avatarUrl = avatarUri (local blob URL) for immediate display, and passes the actual File to createGroupChat (src/libs/actions/Report/index.ts:2039-2057)
    4. createGroupChat includes the file in the OpenReport API call via parameters.file = avatar (src/libs/actions/Report/index.ts:1864-1867)
    5. The server processes the upload and should return avatarUrl with a permanent URL in the response onyxData

    What the PR changed:

    The old code (production) used:

    manipulateAsync(uri, actions, {compress, format}).then((result) => { /* fetch blob, create File */ });

    The new code (staging) uses:

    ImageManipulator.manipulate(uri).crop(...).renderAsync().then(ref => ref.saveAsync({compress, format})).then((result) => { /* same fetch blob, create File */ });

    The new ImageManipulator.manipulate() chain API on web uses an HTML canvas internally. There is a known issue with saveAsync not properly respecting format and compression. If renderAsync() or saveAsync() produces an invalid or empty result on web, the resulting File object would be empty/corrupted. This would cause:

    • The fetch(result.uri) to return an empty blob → 0-byte File created
    • The server receives an empty/invalid file upload → avatar is not stored
    • The server response doesn't include a valid avatarUrl → the optimistic local blob URL gets overwritten → default avatar is displayed

    The display logic in getIconsForGroupChat (src/libs/ReportUtils.ts:3821-3833) uses report.avatarUrl || getDefaultGroupAvatar(report.reportID), so any empty/null/undefined avatarUrl falls back to the default.

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

    1. Verify the regression source: Confirm this is caused by PR Fix - heic context lost #85231 by testing group chat avatar creation on the branch prior to that PR's merge. If confirmed, revert PR Fix - heic context lost #85231 as this is a deploy blocker.

    2. If reverting: Revert src/libs/cropOrRotateImage/index.ts back to using the deprecated manipulateAsync API until the new ImageManipulator.manipulate() chain API is confirmed to work correctly on web for all image types.

    3. If fixing forward: Debug the specific failure point in the new ImageManipulator.manipulate() → renderAsync() → saveAsync() chain on web. The issue is likely that saveAsync on web (which uses canvas.toBlob() or canvas.toDataURL() internally) either fails silently or produces empty output for certain input URIs (e.g., blob URLs from the browser's file picker). Adding validation of the result (check result.uri is non-empty and the fetched blob has non-zero size) with a fallback to the old API would prevent this class of failure.

    What alternative solutions did you explore? (Optional)

    • SequentialQueue changes (PR [No QA] Fix lost/duplicated requests in PersistedRequests (Issues 2, 3, 4, 5) #84622): Also merged into staging but less likely to be the cause. The avatar upload happens when online, so the File object should still be valid when the request is processed. However, if the new async push() creates a timing gap where the blob URL is revoked before the request is sent, this could contribute.

    • Server-side issue: Ruled out because staging and production share the same server, yet the bug only reproduces on the staging client build.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  6. IuliiaHerets commented on Mar 19, 2026

    @IuliiaHerets

    Chrome / v9.3.40-4 PR:85752
    Reproduced

    d85733686bea72289945652d64023d24.mp4
  7. rinej commented on Mar 19, 2026

    @rinej
    Contributor

    It looks like the issue was caused by the refactor from the deprecated manipulateAsync to the new ImageManipulator.manipulate() API.

    I will share the PR with the fix soon, where I reverted to the previous approach, which only affects the web. So the initial fix for #81702 should remain untouched

  8. 9 remaining items

  9. rinej commented on Mar 19, 2026

    @rinej
    Contributor

    Thanks for the picture!

    I updated the branch, and on dev locally looks good

    Could you test the with the newest changes?

    Heres the video with the posted image:
    https://github.com/user-attachments/assets/42206d95-e5ce-485a-91a6-d28b65cdf045

  10. cristipaval commented on Mar 19, 2026

    @cristipaval
    Contributor

    I just triggered a new adhoc build

  11. m-natarajan commented on Mar 19, 2026

    @m-natarajan

    Passed, Chrome, 9.3.40-8 (Kind of delay observed, Latest staging)

    Screen.Recording.2026-03-19.at.17.09.30.mp4
  12. added and removed
    ReviewingHas a PR in review
    DeployBlockerCashThis issue or pull request should block deployment
    on Mar 19, 2026
  13. mountiny commented on Mar 19, 2026

    @mountiny
    Contributor

    Seem slike this is fixed in staging

  14. mountiny commented on Mar 19, 2026

    @mountiny
    Contributor

    @rinej was the bug not from your change then?

  15. rinej commented on Mar 19, 2026

    @rinej
    Contributor

    If it works on staging, then it looks like it 😅 So no changes are needed from that PR

  16. cristipaval commented on Mar 19, 2026

    @cristipaval
    Contributor

    lovely

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

Metadata

Metadata

Assignees

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2Engineering

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions