Skip to content

Multi file attachments#64323

Merged
lakchote merged 27 commits intoExpensify:mainfrom
callstack-internal:feat/59443-multi-file-attachments-clean
Jul 1, 2025
Merged

Multi file attachments#64323
lakchote merged 27 commits intoExpensify:mainfrom
callstack-internal:feat/59443-multi-file-attachments-clean

Conversation

@koko57
Copy link
Contributor

@koko57 koko57 commented Jun 17, 2025

Explanation of Change

🚨 IMPORTANT NOTE 🚨

This PR introduces the ability to send multiple file attachments in a single message.

Key Changes

  • Multiple File Selection: Users can now select and send multiple files as attachments in one message
  • Preview Limitation: While all files are sent successfully, only one file appears in the preview due to missing AttachmentCarousel support
  • Backward Compatibility: Single-attachment functionality remains unchanged and fully functional

Fixed Issues

$ #59443
PROPOSAL:

Tests

PREREQUISITES: all betas / newDotMultiFilesDragAndDrop beta enabled

[WEB / DESKTOP]

  1. Go to any chat
  2. Drag and drop several files onto the Add attachment dropzone
  3. Verify that only the first attachment is shown in the modal (It'll be changed for attachment carousel later)
  4. Click Send
  5. Verify that all the files you dropped are sent
  6. Now instead of dropping files click "+" in the composer
  7. Select Add Attachment
  8. Verify that you're able to select several attachments
  9. Repeat steps 3.-5.

[MOBILE]

  1. Go to any chat
  2. click "+" in the composer
  3. Select Add Attachment
  4. Choose either Photo Library (Choose from Gallery) / Choose Files (Choose file) option
  5. Verify that you're able to select several attachments
  6. Verify that only the first attachment is shown in the modal (It'll be changed for attachment carousel later)
  7. Click Send
  8. Verify that all the files you dropped are sent

[CHECK THE ERROR HANDLING]

  1. Try to drag and drop or attach via composer several files with one that will throw an error (MAX_SIZE > 24 MB, MIN_SIZE < 240 bytes, corrupted image) or try to attach more than 30 files
  2. Verify that the error modal appears with the attachment modal underneath
  3. Verify that the modal has 2 options: Continue and Cancel
  4. Verify that after clicking Continue the modal is closed and you can click Send in the attachment modal
  5. Verify that the valid attachments are sent
  6. Repeat steps 1.-3., this time click Cancel
  7. Verify that both modals - the error modal and the attachment modal close and the attachment flow is discontinued.

[CHECK THE SINGLE FILE FLOW]

  1. Verify that sending attachment via dropping or sending the attachment from the attachment menu works the same like before.
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • 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
    • MacOS: Desktop
  • 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 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 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

Uploading Simulator Screen Recording - iPhone 15 Pro - 2025-06-17 at 15.04.24.mp4…

iOS: mWeb Safari

Uploading Simulator Screen Recording - iPhone 15 Pro - 2025-06-17 at 14.58.05.mp4…

MacOS: Chrome / Safari
Screen.Recording.2025-06-17.at.17.26.33.mp4
Screen.Recording.2025-06-17.at.17.25.18.mp4
MacOS: Desktop
Screen.Recording.2025-06-17.at.17.32.54.mp4
Screen.Recording.2025-06-17.at.17.32.16.mp4

@koko57 koko57 marked this pull request as ready for review June 18, 2025 08:47
@koko57 koko57 requested a review from a team as a code owner June 18, 2025 08:47
@melvin-bot melvin-bot bot requested review from getusha and removed request for a team June 18, 2025 08:47
@melvin-bot
Copy link

melvin-bot bot commented Jun 18, 2025

@getusha 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]

@getusha
Copy link
Contributor

getusha commented Jun 23, 2025

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
    • MacOS: Desktop
  • 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 there are no new alerts related to the canBeMissing param for useOnyx
  • I verified proper code patterns were followed (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
    • 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 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)
  • 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
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 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 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.
  • 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.2025-06-26.at.6.40.52.in.the.evening.mov
Android: mWeb Chrome
Screen.Recording.2025-06-26.at.6.48.51.in.the.evening.mov
iOS: HybridApp
Screen.Recording.2025-06-26.at.9.03.05.at.night.mov
iOS: mWeb Safari
screen-recording-2025-06-26-at-64950-in-the-evening_zUYlFvlR.mp4
MacOS: Chrome / Safari
Screen.Recording.2025-06-25.at.4.06.20.in.the.afternoon.mov
MacOS: Desktop
Screen.Recording.2025-06-26.at.6.55.54.in.the.evening.online-video-cutter.com.mp4

[],
);

const isDirectoryCheck = useCallback((data: FileObject) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of scope but either the name is misleading or is not working as expected.
Doesn't prevent folder upload.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I also noticed that - but as you mentioned - out of scope

tooManyFiles: ({fileLimit}: FileLimitParams) => `You can only upload up to ${fileLimit} files at a time.`,
sizeExceededWithValue: ({maxUploadSizeInMB}: SizeExceededParams) => `Files exceeds ${maxUploadSizeInMB} MB. Please try again.`,
someFilesCantBeUploaded: "Some files can't be uploaded",
sizeLimitExceeded: "Files must be under 10 MB. Any larger files won't be uploaded.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the limit 24 MB?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's a limit for the receipts, it will be used later

maxFileLimitExceeded: "You can upload up to 30 receipts at a time. Any extras won't be uploaded.",
unsupportedFileType: ({fileType}: FileTypeParams) => `${fileType} files aren't supported. Only supported file types will be uploaded.`,
learnMoreAboutSupportedFiles: 'Learn more about supported formats.',
passwordProtected: "Password-protected PDFs aren't supported. Only supported files will be uploaded.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we don't use this. plus password-protected PDFs are supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will use it for the receipts

confirmText={translate(validFilesToUpload.length ? 'common.continue' : 'common.close')}
shouldShowCancelButton={!!validFilesToUpload.length}
cancelText={translate('common.cancel')}
onModalHide={() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets reset fileError state here, since if we rely on useEffect to show the modal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will check it - but probably I made it this way, because when you clear the file error too early, the text will disappear before the modal closes (because modal closing is animated). Same reason the text appears a bit longer and the cancel button disappears earlier here #64323 (comment)

setFile(originalFileName ? {name: originalFileName} : undefined);
}, [originalFileName]);

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we using useEffect? Can't we just set it where we set fileError?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@getusha - same as above #64323 (comment)

@getusha
Copy link
Contributor

getusha commented Jun 23, 2025

BUG: File size limit exceeded error appears when uploading a file under 24MB

Screenshot 2025-06-23 at 9 51 44 at night

@getusha
Copy link
Contributor

getusha commented Jun 23, 2025

It'd be nice if we can have a different copy when every file exceeds the limit.

@getusha
Copy link
Contributor

getusha commented Jun 23, 2025

Bug: A file size limit error briefly appears after pressing "Continue."

  1. Select two files, with one exceeding the file size limit.
  2. Press "Continue" on the "Some files can't be uploaded" error modal.
Screen.Recording.2025-06-23.at.10.58.04.at.night.mov

@koko57
Copy link
Contributor Author

koko57 commented Jun 24, 2025

It'd be nice if we can have a different copy when every file exceeds the limit.

@getusha You mean when all the files dropped are larger than 10MB? (should be 24MB for attachments, I know) I think this copy is descriptive enough for this case, we don't really care how much of the files are exceeding the limit, but I wonder what @Expensify/design Team think?

@shawnborton
Copy link
Contributor

Personally I think it's probably fine as-is. I think this copy already went through our design doc process, right?

@koko57
Copy link
Contributor Author

koko57 commented Jun 24, 2025

Personally I think it's probably fine as-is. I think this copy already went through our design doc process, right?

yep, the copy is from the design doc

@koko57
Copy link
Contributor Author

koko57 commented Jun 27, 2025

@getusha I've made fix for ios, can you check it?

@getusha
Copy link
Contributor

getusha commented Jun 27, 2025

I am still able to reproduce @koko57

Screen.Recording.2025-06-27.at.11.24.18.at.night.mov

Screenshot 2025-06-27 at 10 10 46 at night

LMK if you need the assets

@koko57
Copy link
Contributor Author

koko57 commented Jun 30, 2025

@getusha yes, please, can you send me the assets?

@koko57
Copy link
Contributor Author

koko57 commented Jun 30, 2025

@getusha I've changed the limit of max size to make it easier to throw an error - I cannot reproduce

Simulator.Screen.Recording.-.iPhone.15.-.2025-06-30.at.10.35.07.mp4

@lakchote
Copy link
Contributor

lakchote commented Jul 1, 2025

Since it looks to be asset dependent, and @koko57 can't reproduce, I don't think this should block the merge of this PR it seems an edge-case, and it can always be done as a follow-up.

cc @getusha

@getusha
Copy link
Contributor

getusha commented Jul 1, 2025

Can't upload multiple file attachments after a multi file error

  1. Pick two attachments with one being invalid
  2. Cancel
  3. Pick two valid attachments
Screen.Recording.2025-07-01.at.10.45.29.in.the.morning.mov

Doesn't have to be a blocker

@getusha
Copy link
Contributor

getusha commented Jul 1, 2025

For the iOS issue there is a noticeable delay that could be relevant

Screen.Recording.2025-07-01.at.11.40.42.in.the.morning.mov

Will again test it after the refactor

@koko57
Copy link
Contributor Author

koko57 commented Jul 1, 2025

yeah, for the ios, I think we should add a loader (like it's for selecting receipts in the IOU flow), it could be done later, now I will fix the issue with the modal on the web

@koko57
Copy link
Contributor Author

koko57 commented Jul 1, 2025

@getusha can you check once again #64323 (comment) and send me the attachments if it's still reproducible?

@koko57
Copy link
Contributor Author

koko57 commented Jul 1, 2025

@getusha also please retest this one: #64323 (comment) (fixed)

@getusha
Copy link
Contributor

getusha commented Jul 1, 2025

@getusha can you check once again #64323 (comment) and send me the attachments if it's still reproducible?

Couldn't reproduce but i think it's a potential race condition which boils down to the delay

Screen.Recording.2025-07-01.at.1.03.53.in.the.afternoon.mov

You can replicate the freeze by trying to open the create popover before the error modal appears

@lakchote lakchote changed the title [NoQA] Multi file attachments Multi file attachments Jul 1, 2025
@lakchote lakchote merged commit ec2e890 into Expensify:main Jul 1, 2025
20 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Jul 1, 2025

✋ 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
Contributor

github-actions bot commented Jul 2, 2025

🚀 Deployed to staging by https://github.com/lakchote in version: 9.1.74-2 🚀

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

@mountiny
Copy link
Contributor

mountiny commented Jul 2, 2025

We have reverted to fix this blocker #65317, please add those QA steps to the next attempt 🙌 Thank you!

@github-actions
Copy link
Contributor

github-actions bot commented Jul 3, 2025

🚀 Deployed to production by https://github.com/puneetlath in version: 9.1.74-10 🚀

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

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.

8 participants