Skip to content

Show an edited file attachment as [Attachment] in the chat list - #102746

Merged
lakchote merged 6 commits into
Expensify:mainfrom
mukhrr:fix/101693
Oct 26, 2026
Merged

lakchote merged 6 commits into
Expensify:mainfrom
mukhrr:fix/101693

Conversation

@mukhrr

@mukhrr mukhrr commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

When a file comment is edited, the server drops data-expensify-source from the file link, so the parser no longer reads it as an attachment and the chat list row shows the file name instead of [Attachment]. The row text now swaps a file link for [Attachment] using the same check that decides whether the chat draws it as a file card.

Fixed Issues

$ #101693
PROPOSAL:

Tests

  1. Open any chat
  2. Send a .csv file as an attachment
  3. Verify the chat's row in the LHN shows [Attachment]
  4. Edit the comment, change the file name and save
  5. Verify the row still shows [Attachment]
  6. Edit the comment again, add some text before the file link and save
  7. Verify the row shows the text followed by [Attachment]
  8. Edit the comment again, change only the text and save
  9. Verify the row shows the new text followed by [Attachment]
  10. Edit the comment again, change the file link's URL to https://example.com/file.csv and save
  11. Verify the message shows a plain link and the row shows the link's label
  12. Send a new comment with a typed link to the URL of a file sent earlier, e.g. see [old sheet](<file URL>)
  13. Verify the message shows a plain link and the row shows see old sheet
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline
  2. Do steps 1 to 9 of the Tests
  3. Verify the row shows [Attachment] after each edit
  4. Go back online and verify the row still shows [Attachment]

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 followed proper code patterns (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 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)
  • 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.
  • 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
101693-android-app.mp4
Android: mWeb Chrome
101693-android-web.mp4
iOS: Native
101693-ios-app.mp4
iOS: mWeb Safari
101693-ios-web.mp4
MacOS: Chrome / Safari
web.mp4

@mukhrr mukhrr changed the title Show an edited file attachment as [Attachment] in the chat list [HOLD https://github.com/Expensify/App/pull/101717] Show an edited file attachment as [Attachment] in the chat list Oct 1, 2026
@mukhrr mukhrr changed the title [HOLD https://github.com/Expensify/App/pull/101717] Show an edited file attachment as [Attachment] in the chat list [HOLD] Show an edited file attachment as [Attachment] in the chat list Oct 1, 2026
@mukhrr

mukhrr commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Holding for #101717

@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/libs/AttachmentAnchorUtils.ts 100.00% <100.00%> (ø)
src/libs/ReportActionMessageUtils.ts 100.00% <100.00%> (ø)
src/libs/ReportActionsUtils.ts 84.42% <100.00%> (ø)
... and 9 files with indirect coverage changes

The server drops data-expensify-source from a file link when the comment
is edited and keeps only data-attachment-id, so the parser read the link
as plain text and the row showed the file name. The row text and the
attachment-only check now also accept data-attachment-id. A typed link to
a chat-attachments URL never gets that attribute, so it keeps its label.
@mukhrr

mukhrr commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

#101717 is merged. Now working on this PR..

@mukhrr mukhrr changed the title [HOLD] Show an edited file attachment as [Attachment] in the chat list Show an edited file attachment as [Attachment] in the chat list Oct 23, 2026
The row text now treats a link as a file exactly when the chat draws it as
a card: isAttachmentAnchorTag or isOwnAttachmentURL, both from
AttachmentAnchorUtils. A file link edited to point at another host, or a
pasted link to another message's file, keeps its label.

isReportMessageAttachment goes back to main. Widening it moved edited
file-only messages onto AttachmentCommentFragment instead of the
TextCommentFragment path the card fix relies on, and the row text alone
already reads them as [Attachment].
@mukhrr
mukhrr marked this pull request as ready for review October 23, 2026 15:27
@mukhrr
mukhrr requested review from a team as code owners October 23, 2026 15:27
@melvin-bot
melvin-bot Bot requested review from brunovjk and removed request for a team October 23, 2026 15:27
@melvin-bot

melvin-bot Bot commented Oct 23, 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]

@melvin-bot
melvin-bot Bot requested a review from trjExpensify October 23, 2026 15:27
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-23T15:27:12.315736Z 6b779f0 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@melvin-bot
melvin-bot Bot removed the request for review from a team October 23, 2026 15:27
Comment thread src/libs/AttachmentAnchorUtils.ts Outdated
wrapAttachmentAnchorsInBlocks and replaceAttachmentAnchorsWithText both
decided on their own whether an anchor is a file card, so a change to that
rule had to be made twice. Both now call isFileCardAnchor. The card markup
is unchanged.
trjExpensify
trjExpensify previously approved these changes Oct 23, 2026

@trjExpensify trjExpensify 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. 👍

# Conflicts:
#	tests/unit/ReportActionsUtilsTest.ts
@mukhrr

mukhrr commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

@brunovjk we are good to go here. can you pls review?! thanks!

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@brunovjk

brunovjk commented Oct 26, 2026 •

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 any copy / text that was added to the app 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 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 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 the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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
102746_android_native.mov
Android: mWeb Chrome
102746_android_web.mov
iOS: HybridApp
102746_ios_native.mov
iOS: mWeb Safari
102746_ios_web.mov
MacOS: Chrome / Safari
102746_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 review from chuckdries and lakchote October 26, 2026 16:46

@lakchote lakchote 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.

Looks good, just one NAB.

}
// Sometime html can be an empty string
return reportAction?.message?.reduce((acc, curr) => `${acc}${getTextFromHtml(curr?.html || curr?.text)}`, '') ?? '';
return reportAction?.message?.reduce((acc, curr) => `${acc}${getTextFromHtml(curr?.html || curr?.text, reportAction.reportActionID)}`, '') ?? '';

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.

NAB: when message is a single object, the early return above uses getReportActionText, which still calls Parser.htmlToText directly. Can we run replaceAttachmentAnchorsWithText there too, so the row shows [Attachment] for both shapes?

@lakchote
lakchote merged commit 456fdb4 into Expensify:main Oct 26, 2026
35 of 37 checks passed
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/lakchote in version: 9.5.21-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update is needed. This bug fix keeps the chat row preview showing [Attachment] after you edit a file comment, which is what users already expect, and it doesn't make any help article sentence incorrect.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/lakchote in version: 9.5.23-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update is needed. This bug fix keeps the chat row preview showing [Attachment] after you edit a file comment, which is what users already expect, and it doesn't make any help article sentence incorrect.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.5.23-3 🚀

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

Bundle Size Analysis (Sentry):

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants