Skip to content

fix: update CSV upload options for Members#65398

Merged
rlinoz merged 43 commits intoExpensify:mainfrom
nkdengineer:fix/65056
Aug 19, 2025
Merged

fix: update CSV upload options for Members#65398
rlinoz merged 43 commits intoExpensify:mainfrom
nkdengineer:fix/65056

Conversation

@nkdengineer
Copy link
Contributor

@nkdengineer nkdengineer commented Jul 3, 2025

Explanation of Change

Fixed Issues

$ #65056
PROPOSAL: #65056 (comment)

Tests

  • Import member with the role column is not empty
  1. Go to the workspace member
  2. Click More option -> Import Spreadsheet
  3. Import a file with email, submitTo, approveTo, role columns (all members have the role column)
  4. Complete this flow
  5. Verify that the members are added to the WS with the correct role
  6. Go to workflow page
  7. Verify that the workflow is added.
  • Import member without role column
  1. Go to the workspace member
  2. Click More option -> Import Spreadsheet
  3. Import a file with email, submitTo, approveTo, role columns (at least one member doesn't have the role column)
  4. Click import
  5. Verify that the confirm page appears
  6. Select a role for new members
  7. Click import
  8. Verify that all new members are added with the selected role
  9. Go to workflow
  10. Verify that the new workflow is added.
  • Verify that no errors appear in the JS console

Offline tests

Same as tests

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
    • 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 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 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
Screen.Recording.2025-07-31.at.15.01.03.mov
Screen.Recording.2025-07-31.at.14.43.00.mov
Android: mWeb Chrome
android-mweb.mov
Screen.Recording.2025-07-31.at.14.53.00.mov
iOS: Native
Screen.Recording.2025-07-31.at.15.00.18.mov
Screen.Recording.2025-07-31.at.14.51.56.mov
iOS: mWeb Safari
ios-mweb.mov
Screen.Recording.2025-07-31.at.14.53.40.mov
MacOS: Chrome / Safari
web-resize.mp4
Screen.Recording.2025-07-31.at.14.40.14.mov
MacOS: Desktop
desktop.mov
Screen.Recording.2025-07-31.at.14.56.03.mov

@nkdengineer nkdengineer marked this pull request as ready for review July 4, 2025 10:22
@nkdengineer nkdengineer requested a review from a team as a code owner July 4, 2025 10:22
@melvin-bot melvin-bot bot requested review from sobitneupane and removed request for a team July 4, 2025 10:22
@melvin-bot
Copy link

melvin-bot bot commented Jul 4, 2025

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

@nkdengineer
Copy link
Contributor Author

I can't record in native because of the app crash, will add later. And I'll fix the typescript check soon, it's related to translation

@danielrvidal
Copy link
Contributor

@nkdengineer @sobitneupane is this ready to review now? Can we prioritize this one as it's for a larger customer.

@sobitneupane
Copy link
Contributor

Sure @danielrvidal

@nkdengineer Could you please fix typescript checks?

@sobitneupane
Copy link
Contributor

@nkdengineer Could you please add a CSV test file as well?

@sobitneupane
Copy link
Contributor

@nkdengineer We would only like to add the columns to the existing “Import Spreadsheet” feature on the Members page.
We’ve descoped any changes related to the Workflows page for now.

With that, I think we should proceed on this issue to accept the SubmitTo and approveTo columns in the existing CSV importer found in Members. It's a front-end only change given this:

I updated the original post so it only calls out adding submitsTo and appovesTo, and only applies to the Members page. We can add this option to the workflows page down the road.

@nkdengineer
Copy link
Contributor Author

nkdengineer commented Jul 8, 2025

thanks for your review @sobitneupane, i'll give an update soon

@nkdengineer
Copy link
Contributor Author

@nkdengineer We would only like to add the columns to the existing “Import Spreadsheet” feature on the Members page.
We’ve descoped any changes related to the Workflows page for now.

@sobitneupane I fixed

@nkdengineer
Copy link
Contributor Author

@sobitneupane Except for en.ts and es.ts, I used ChatGPT with the 4.o model for all other languages.

@sobitneupane
Copy link
Contributor

@nkdengineer You probably missed this

@nkdengineer Could you please add a CSV test file as well?

@nkdengineer
Copy link
Contributor Author

@sobitneupane here you go

sample.xlsx

@sobitneupane
Copy link
Contributor

sobitneupane commented Jul 10, 2025

@nkdengineer After importing the spreadsheet, we should display the approvers in the workflow.

In this comment, I only meant that we don’t need to add an "Import approval workflow" button on the Workflow page. However, I do believe we want to show the imported members in the workflow section.

Screenshot 2025-07-10 at 13 41 20

@danielrvidal Could you please confirm this?

@danielrvidal
Copy link
Contributor

Correct, if the approval flows are updated from columns being uploard in the members page, they would need to be accounted for in the workflows page.

@JmillsExpensify
Copy link
Contributor

Yes, for sure.

@danielrvidal
Copy link
Contributor

@sobitneupane @nkdengineer let me know if there are any questions before getting started on this one.

@sobitneupane
Copy link
Contributor

@nkdengineer Could you please update the PR to address this comment?

@nkdengineer
Copy link
Contributor Author

@sobitneupane i'm checking now

@nkdengineer
Copy link
Contributor Author

@sobitneupane it seems that for users in the forwardsTo and submitsTo fields, we need to invite them to the workspace first, otherwise the BE will not update them as members of the workspace. So should we update the BE or update the frontend to add submitTo/forwardTo to the employees parameter cc @danielrvidal

@trjExpensify
Copy link
Contributor

@rlinoz cc'ing you in here for eyes to help. I haven't bee subscribed to this PR to date!

@sobitneupane it seems that for users in the forwardsTo and submitsTo fields, we need to invite them to the workspace first, otherwise the BE will not update them as members of the workspace

Yeah, this is just how the spreadsheet for import works and has done since the dawn of time. Every user being added to the workspace has to be in the Email column of the CSV upload to get added to the workspace. Else, if a user is only in the submitsTo column, they won't be.

@nkdengineer
Copy link
Contributor Author

@tgolen Updated all your suggestions.

@danielrvidal
Copy link
Contributor

Aw got it, I'll wait for that. My bad I thought it was out.

Copy link
Contributor

@tgolen tgolen left a comment

Choose a reason for hiding this comment

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

Thanks! Just a couple small things

Comment on lines +72 to +73
// eslint-disable-next-line react-compiler/react-compiler
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Contributor

Choose a reason for hiding this comment

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

Bump for this one

@rlinoz
Copy link
Contributor

rlinoz commented Aug 19, 2025

@nkdengineer can you please merge main again so perf tests pass?

@nkdengineer
Copy link
Contributor Author

Done.

@rlinoz rlinoz merged commit 8b4cc1a into Expensify:main Aug 19, 2025
20 checks passed
@OSBotify
Copy link
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.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/rlinoz in version: 9.1.98-0 🚀

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

@unzig21
Copy link

unzig21 commented Aug 23, 2025

Hello,

I tested this PR and have some doubts.
If we clicked "Add approval workflow" on the Collect plan WS, the RHP to upgrade to the Control plan will appear. But when we upload the CSV file with Advanced Approvals via import Members, the Workflows will update like Advanced Approvals.
Is this expected?

Because I think it can be exploited if the Advance Approval can be set via uploading the CSV file via the Import Member without upgrading the Plan.

video.PR65398.mp4

Thanks

@unzig21
Copy link

unzig21 commented Aug 25, 2025

Hello,

I tested this PR and have some doubts. If we clicked "Add approval workflow" on the Collect plan WS, the RHP to upgrade to the Control plan will appear. But when we upload the CSV file with Advanced Approvals via import Members, the Workflows will update like Advanced Approvals. Is this expected?

Because I think it can be exploited if the Advance Approval can be set via uploading the CSV file via the Import Member without upgrading the Plan.

video.PR65398.mp4
Thanks

Could you please provide the answer @nkdengineer ?

@trjExpensify
Copy link
Contributor

But when we upload the CSV file with Advanced Approvals via import Members, the Workflows will update like Advanced Approvals. Is this expected?

Because I think it can be exploited if the Advance Approval can be set via uploading the CSV file via the Import Member without upgrading the Plan.

Nice catch, they shouldn't be allowed to configure advanced approvals on the collect plan. The way we handle that on Classic seems to be by just adding the email addresses only - and everyone submits to the default approver already configured on the workspace. So I think we can do the same in NewDot.

2025-08-26_11-02-04.mp4

@nkdengineer
Copy link
Contributor Author

@trjExpensify In the collect workspace, after we upload a CSV with submitsTo/approvesTo. The backend still updates this data, and we can see it in the ND. In OldDot, we don't see this because it's only shown in the control workspace.

@trjExpensify
Copy link
Contributor

Ah, so you're saying:

  1. We store the submitsTo/approvesTo on the members uploaded via the CSV
  2. We do also however leave the collect workspace on BASIC approval mode and the default approver is who the expense reports are submitted to regardless.
  3. If the admin tries to switch to advanced approval, they are prompted to upgrade the workspace to Control
  4. If they complete the upgrade, the submitsTo/approvesTo's from (1) above are then shown and set accordingly.

Is that, right? If so, then in NewDot I would expect to:

  1. Store the submitsTo/approvesTo on the members uploaded via the CSV
  2. Leave the collect workspace on BASIC approval mode with the default workflow shown only
  3. If the admin clicks "Add approval workflow", prompt to upgrade the workspace to Control.
  4. If they complete the upgrade, the submitsTo/approvesTo's from (1) above are then shown and set in the additional workflows accordingly.

CC: @JmillsExpensify

@nkdengineer
Copy link
Contributor Author

nkdengineer commented Aug 26, 2025

If they complete the upgrade, the submitsTo/approvesTo's from (1) above are then shown and set accordingly.

Yes.

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.1.98-12 🚀

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

@danielrvidal
Copy link
Contributor

I feel like what @trjExpensify is expecting would work well. I think that will make this functional for most cases and if we end up wanting to add some polish where if the user adds advanced approvals while on Collect, we can have better messaging. But I think I'd probably add that later and only if we hear confusion. I feel like that will be more of an edge case than something a lot of people are hitting. If you are managing your approvals with CSVs , you likely hit the Control upgrade far before that.

const employee = policy?.employeeList?.[curr.email];
if (employee) {
if (curr.role !== employee.role) {
if (curr.role !== employee.role || curr.submitsTo !== employee.submitsTo || curr.forwardsTo !== employee.forwardsTo) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Came from this issue
More context here

</PressableWithoutFeedback>
</FixedFooter>
<ConfirmModal
isVisible={spreadsheet?.shouldFinalModalBeOpened}
Copy link
Contributor

Choose a reason for hiding this comment

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

This second modal caused duplicate modal to appear, which caused #74907

@sobitneupane
Copy link
Contributor

This case was not handled in the PR.

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.