Skip to content

Chat - Edited file name is not saved when editing file name in offline mode #98696

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.4.54-0
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #97935
Email or phone of affected tester (no customers): sdsiodjnosdjiodsj@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.5 / Chrome
App Component: Other

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to any chat.
  3. Go offline.
  4. Send a text with CSV fule attachment.
  5. Right click on the message > Edit comment.
  6. Edit the file name and save it.
  7. Right click on the message > Edit comment.

Expected Result:

The edited file name will be saved.

Actual Result:

The edited file name is not saved.
It still shows the original file name despite editing it.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7233922_1786740428165.4.mp4

View all open jobs on GitHub

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

Activity

  1. added
    DeployBlockerCash
    Bug
    on Aug 14, 2026
  2. applause-bot commented on Aug 14, 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/79f629beb3346576090c8462812003e9c817667da3cca5c8fe776ac71ca694bc

  3. melvin-bot commented on Aug 14, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #97935

  4. melvin-bot commented on Aug 14, 2026

    @melvin-bot

    @youssef-lr @brunovjk you have been assigned to this deploy blocker because you reviewed the offending PR: #97935

  5. github-actions commented on Aug 14, 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.
  6. melvin-bot commented on Aug 14, 2026

    @melvin-bot

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

  7. MelvinBot commented on Aug 14, 2026

    @MelvinBot
    Contributor

    Deploy Blocker Analysis

    Root cause: Confirmed — #97935 ("Show Edit comment for text and attachment messages while the attachment uploads") introduced this. When you rename a still‑pending (offline) attachment and save, the edit path strips the entire local attachment reference — including the edited name — out of the saved draft, then re‑renders and re‑queues the message with the original filename. High confidence.

    Recommendation: Roll forward with a targeted fix — do not revert. A revert re‑breaks the intended feature from #94878 (editing a text+attachment message while it uploads). This is a narrow offline edge case (renaming an attachment's link text while pending); text edits and the attachment itself are preserved, so there's no data loss.

    Why #97935 is the cause

    Before #97935, canEditReportAction treated an optimistic text + attachment action as non‑editable, so "Edit comment" was never offered while the message was pending/offline. #97935 changed that gate so only attachment‑only optimistic comments stay non‑editable:

    src/libs/ReportUtils.ts:5427-5431:

    // Only an attachment-only comment has nothing to edit while it uploads; text keeps it editable throughout.
    const isOptimisticAttachment = !!reportAction?.isOptimisticAction && !!reportAction?.isAttachmentOnly;

    (previously && (!!reportAction?.isAttachmentOnly || !!reportAction?.isAttachmentWithText))

    The exact path in this bug — opening "Edit comment" on a still‑pending (offline) text+CSV message — is only reachable because of #97935, and every helper the edit path now runs through (replaceLocalAttachmentReferences, getUploadingAttachmentHtmlFromComment, isUploadingAttachmentRemovedFromDraft) was introduced by this PR.

    Root cause — the edited name is dropped in three places

    While pending (offline), the attachment appears in the edit draft as a local markdown reference, e.g. [myfile.csv](blob:…). Renaming it to [renamed.csv](blob:…) and saving:

    1. Saved draft — replaceLocalAttachmentReferences takes the "still uploading" branch and strips the whole reference, discarding the edited name:

    src/libs/ReportUtils.ts:6688-6718:

    const isStillUploading = !currentCommentHtml || currentCommentHtml.includes(CONST.ATTACHMENT_OPTIMISTIC_SOURCE_ATTRIBUTE);
    if (isStillUploading) {
        return draftMarkdown.replace(localAttachmentReferenceRegex, '').trim();   // edited filename discarded here
    }

    2. Optimistic render — the attachment is re‑appended using the original, unedited optimistic tag:

    src/libs/actions/Report/index.ts:3538-3569:

    const uploadingAttachmentHtml = shouldRemoveQueuedAttachment ? undefined : getUploadingAttachmentHtmlFromComment(originalCommentHTML);
    const optimisticHtml = uploadingAttachmentHtml ? `${htmlForNewComment}<br /><br />${uploadingAttachmentHtml}` : htmlForNewComment;

    3. Queued request — because the attachment was kept, shouldRemoveQueuedAttachment is false, so the queued AddTextAndAttachment request re‑attaches with the original filename when it syncs (src/libs/actions/RequestConflictUtils.ts:280-302).

    Why it's a real regression (not pre‑existing): once synced (online), the draft holds an https reference, which localAttachmentReferenceRegex (only blob:|file:|content:) does not match — so an online rename survives. Only the offline/pending case throws the edit away.

    Targeted fix — preserve the edited name through the pending path

    Three coordinated changes:

    1. replaceLocalAttachmentReferences (ReportUtils.ts:6695-6698) — in the isStillUploading branch, detect when the draft's link text/name differs from the original attachment name and carry the new name forward (rewrite the reference to the synced/queued form with the edited name) rather than returning empty.
    2. Optimistic render (Report/index.ts:3567-3568) — instead of re‑appending the untouched getUploadingAttachmentHtmlFromComment(originalCommentHTML), apply the edited name to that tag (rewrite its data-name / link text / alt) so the pending message shows the new name immediately.
    3. Queued request (RequestConflictUtils.ts resolveEditCommentWithNewAddCommentRequest, ~L296) — when the attachment is kept but renamed, update currentAddComment.data.file.name (and the attachment name param) so the server stores the new filename on sync.

    Assignees are already correct: mukhrr (author) and reviewers youssef-lr, brunovjk. Keep the DeployBlockerCash label (frontend App regression, new‑feature).


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement this to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.

  8. mukhrr commented on Aug 15, 2026

    @mukhrr
    Contributor

    hmm not sure if this is a regression or not. On Production, editing filename makes it just link while losing format.

    What it does currently:

    REC-20260815061049.mp4

    What I mean/propose:

    REC-20260815061213.mp4

    cc @youssef-lr @brunovjk

  9. Beamanator commented on Aug 16, 2026

    @Beamanator
    Contributor

    Ya I wonder why the OP says N/A - new feature, doesn't exist in prod - it seems like there is a bug reproducible on prod, so it would make sense this is NAB - is that how you understand it too @mukhrr ?

  10. mukhrr commented on Aug 17, 2026

    @mukhrr
    Contributor

    @Beamanator Alex, exactly!

  11. mukhrr commented on Aug 17, 2026

    @mukhrr
    Contributor

    @Beamanator I think they reported the exact issue #98743. Can we close this and continue in #98743 as follow up? cc @youssef-lr @brunovjk

  12. added
    Daily
    and removed
    DeployBlockerCash
    Hourly
    on Aug 17, 2026
  13. Beamanator commented on Aug 17, 2026

    @Beamanator
    Contributor

    will demote this but i'm not sure if we want to close this or not, will let @youssef-lr deal with that 👍

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

Metadata

Metadata

Labels

BugDailyEngineering

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions