Skip to content

[CP Staging] Keep a video attachment when a comment is edited twice while it uploads - #98702

Merged
Beamanator merged 2 commits into
Expensify:mainfrom
mukhrr:fix/94878-regressions
Aug 17, 2026
Merged

Beamanator merged 2 commits into
Expensify:mainfrom
mukhrr:fix/94878-regressions

Conversation

@mukhrr

@mukhrr mukhrr commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Editing a comment twice while its video was still uploading dropped the video for good.

The optimistic message re-appends the still-uploading attachment so it stays on screen while the edit is saved, but the tag was matched with a pattern that only covers an opening tag. A video keeps its label between the tags, so what got stored was a truncated <video …> with no closing tag. That parses back to nothing, so the second edit's draft had no reference to the attachment left in it, the edit was read as the user having deleted it, and the file was dropped from the queued send.

Videos are now matched as whole elements. The same assumption was in the path that swaps a local reference for the synced attachment once the upload lands, where a truncated element would have produced empty markdown and wiped the attachment there too, so both are fixed.

Second, the attachment was put back after a fixed separator, so an edit that deleted all of the text left the separator with nothing in front of it and the comment reopened with blank lines above the attachment. The parts are joined now, and an empty one is dropped.

Fixed Issues

$ #98692
PROPOSAL:

Tests

  1. Open any chat.
  2. Type a message in the composer, then use + > Add attachment, pick a video, and send it, so the text and the video go out as one message.
  3. While the video is still uploading, right click (long press on mobile) the message and choose "Edit comment". Use a large video or throttle the network to Slow 3G so the upload window is long enough to catch.
  4. Change the text and save.
  5. Verify the video is still shown on the message.
  6. Right click the message and choose "Edit comment" a second time.
  7. Verify the draft still contains the video reference, and that saving again keeps the video on the message.
  8. Repeat steps 1 to 7 with an image and with a non-media file (e.g. a .csv) and verify both still behave the same as before.
  9. Send another text + attachment message, choose "Edit comment", delete all of the text including the empty lines, and save.
  10. Choose "Edit comment" again and verify the attachment sits at the top of the composer, with no blank lines above it.
  • Verify that no errors appear in the JS console

Offline tests

  1. Open any chat and type a message in the composer.
  2. Go offline.
  3. Attach a video and send, so the message stays pending.
  4. Long press the message, choose "Edit comment", change the text, and save.
  5. Verify the video is still shown on the message.
  6. Long press the message and choose "Edit comment" again, then save.
  7. Verify the video is still shown, and does not disappear.
  8. Go back online and wait for the message to sync.
  9. Verify the synced message still has the video.

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
REC-20260815063928.mp4

Matching only the opening tag stored a truncated video that parsed back
to nothing, so a second edit read the attachment as deleted and dropped
it from the queued send. The synced swap path had the same assumption.
@mukhrr
mukhrr requested review from a team as code owners August 15, 2026 01:36
@melvin-bot
melvin-bot Bot requested review from brunovjk and flaviadefaria and removed request for a team and flaviadefaria August 15, 2026 01:36
@melvin-bot

melvin-bot Bot commented Aug 15, 2026

Copy link
Copy Markdown

@brunovjk Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@github-actions

Copy link
Copy Markdown
Contributor

🚧 Beamanator has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

This comment has been minimized.

@brunovjk

Copy link
Copy Markdown
Contributor

@mukhrr The original issue seems to have been resolved, but I found an inconsistency and wonder if it falls within the scope of our issue:

  • Go to any chat.
  • Go offline.
  • Send a text with a video attachment.
  • Right-click on the message > Edit comment.
  • Delete the text, along with the empty lines, and save it.
  • Right-click on the message > Edit comment.

Expected Result:

  • Only the video link is present, at the top of the composer.

Actual Result:

  • There is a two-line gap, the first being where the initial comment was, before the video link.
Screenshot 2026-08-17 at 11 03 04
bug.mov

@mukhrr

mukhrr commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

@brunovjk Do you think this is NAB?

@brunovjk

Copy link
Copy Markdown
Contributor

I'm not sure,what do you think, @youssef-lr? I can't reproduce the bug in production because the edit option isn't available while the file is still uploading or offline.

…ment

The still-uploading attachment was appended after a fixed separator, so
deleting the whole comment left the separator with nothing before it and
the next edit reopened with blank lines above the attachment.
@mukhrr
mukhrr force-pushed the fix/94878-regressions branch from c989798 to 88ea76b Compare August 17, 2026 15:13
@mukhrr

mukhrr commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

@brunovjk anyways, I fixed it

@brunovjk

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Screen.Recording.2026-08-17.at.12.38.50.mov
Android: mWeb Chrome
iOS: HybridApp
Screen.Recording.2026-08-17.at.12.50.50.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
98702_web_chrome.mov

@brunovjk brunovjk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@melvin-bot
melvin-bot Bot requested a review from youssef-lr August 17, 2026 15:53
@Beamanator

Copy link
Copy Markdown
Contributor

@mukhrr can you pull main or something to retrigger all the failed checks?

@Beamanator

Copy link
Copy Markdown
Contributor

nvm i manually retried them all :D

@Beamanator Beamanator left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good here!

@Beamanator
Beamanator merged commit 12b0038 into Expensify:main Aug 17, 2026
39 of 70 checks passed
@Beamanator Beamanator changed the title Keep a video attachment when a comment is edited twice while it uploads [CP Staging] Keep a video attachment when a comment is edited twice while it uploads Aug 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚧 Beamanator has triggered a test Expensify/App build. You can view the workflow run here.

OSBotify pushed a commit that referenced this pull request Aug 17, 2026
Keep a video attachment when a comment is edited twice while it uploads

(cherry picked from commit 12b0038)

(cherry-picked to staging by Beamanator)
@OSBotify OSBotify added the CP Staging marks PRs that have been CP'd to staging label Aug 17, 2026
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Cherry-picked to staging by https://github.com/Beamanator in version: 9.4.54-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 failure ❌

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 I reviewed the changes in this PR against the help site content under docs/articles.

No help site changes are required.

This is a bug fix that restores previously-intended behavior — it keeps a video attachment on a message when the comment is edited twice while the upload is still in progress (and fixes a related blank-lines issue when all text is deleted). The change is entirely internal (ReportUtils.ts and actions/Report/index.ts):

  • No new feature, setting, tab, or button is introduced.
  • No existing documented workflow changes — editing a message and keeping its attachment is the expected behavior the docs already assume.
  • The user-facing outcome after this fix matches what the help site already describes.

Because there's no behavioral or UI change that the public help articles need to reflect, I did not create a draft docs PR.

mukhrr, please confirm you agree no help site update is needed here. If you believe an article should still be updated, reply with the specific behavior/article and I'll draft a docs PR.

@OSBotify

Copy link
Copy Markdown
Contributor

🔁 Filed a Staging retest request for deploy blockers #98692 after this PR was cherry-picked to staging.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Cherry-picked to staging by https://github.com/Beamanator in version: 9.4.54-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Re-confirming my earlier review: no help site changes are required for this PR.

This is a bug fix that restores previously-intended behavior — it keeps a video attachment on a message when the comment is edited twice while its upload is still in progress, and fixes a related blank-lines issue when all text is deleted. The change is internal only (src/libs/ReportUtils.ts, src/libs/actions/Report/index.ts), with no new feature, setting, tab, button, or workflow change that the public articles under docs/articles would need to reflect. So there was nothing to draft a docs PR for (and thus no PR to label HelpDot or assign).

mukhrr, please confirm you agree no help site update is needed here. If you believe a specific article should still be updated, reply with the behavior/article and I'll draft a docs PR.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/Beamanator in version: 9.4.54-4 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Cherry-picked to staging by https://github.com/Beamanator in version: 9.4.55-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Still no help site changes required — same conclusion as my earlier reviews on this PR.

This is a bug fix that restores intended behavior (keeping a video attachment on a message when the comment is edited twice while it uploads, plus a blank-lines fix). The change is internal only (ReportUtils.ts, actions/Report/index.ts) with no new feature, setting, tab, button, or workflow change for the public articles under docs/articles to reflect. No draft docs PR was created.

mukhrr, if you believe a specific article should still be updated, reply with the behavior/article and I'll draft a docs PR.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/Beamanator in version: 9.4.55-4 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 failure ❌

Bundle Size Analysis (Sentry):

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

Labels

CP Staging marks PRs that have been CP'd to staging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants