Bulk move expenses to a new report#71778
Conversation
|
@parasharrajat 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] |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
| }); | ||
|
|
||
| const session = useSession(); | ||
| const userPolicies = Object.values(allPolicies ?? {}).filter((policy) => isPolicyMemberWithoutPendingDelete(session?.email, policy) && policy?.type !== CONST.POLICY.TYPE.PERSONAL); |
There was a problem hiding this comment.
| const userPolicies = Object.values(allPolicies ?? {}).filter((policy) => isPolicyMemberWithoutPendingDelete(session?.email, policy) && policy?.type !== CONST.POLICY.TYPE.PERSONAL); | |
| const userPolicies = Object.values(allPolicies ?? {}).filter((policy) => isPolicyMemberWithoutPendingDelete(session?.email, policy) && isPaidGroupPolicy(policy)); |
Even though it is same but this one is more declarative.
| return {policyForMovingExpensesID: undefined, policyForMovingExpenses: undefined, shouldSelectPolicy: true}; | ||
| } | ||
|
|
||
| return {policyForMovingExpensesID: undefined, policyForMovingExpenses: undefined, shouldSelectPolicy: false}; |
There was a problem hiding this comment.
| return {policyForMovingExpensesID: undefined, policyForMovingExpenses: undefined, shouldSelectPolicy: false}; | |
| return {policyForMovingExpenses: undefined, shouldSelectPolicy: false}; |
Seems unnecessary when we are exporting policyForMovingExpenses
There was a problem hiding this comment.
in some cases we will need the id only so why not export it
There was a problem hiding this comment.
We can get it from policyForMovingExpenses variable, so I would keep one source
There was a problem hiding this comment.
I don't like the optional chaining everywhere when we really don't need to use the whole object
There was a problem hiding this comment.
If it won't be used extensively, I will remove it
src/libs/ReportUtils.ts
Outdated
| // temporary check for Search Page only | ||
| isSearchPageOption?: boolean, |
There was a problem hiding this comment.
Can you please add more explanation about this temporary check? Will we remove it in future? if so, please add todo for cleanup.
There was a problem hiding this comment.
Not sure yet if we will remove it - if we will have the upgrade path from the Search Page it will no longer be necessary. But it of course will depend on the Expensify team decision
src/libs/ReportUtils.ts
Outdated
| const isUserWorkspaceMember = Object.values(allPolicies ?? {}).find( | ||
| (policyItem) => policyItem?.employeeList?.[currentUserEmail ?? ''] && policyItem?.type !== CONST.POLICY.TYPE.PERSONAL, | ||
| ); |
There was a problem hiding this comment.
We should use something similar to getActivePolicies here but you can check other methods in policyutils or create more suitable one.
There was a problem hiding this comment.
it will probably be changed later, so I don't want to create an util now that won't be used later
There was a problem hiding this comment.
But we need to check for non-pending deletion policy here too, so we should use either getActivePolicies or add code here.
|
|
||
| const [policies, fetchStatus] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true}); | ||
| const currentUserPersonalDetails = useCurrentUserPersonalDetails(); | ||
| const isASAPSubmitBetaEnabled = Permissions.isBetaEnabled(CONST.BETAS.ASAP_SUBMIT, allBetas); |
There was a problem hiding this comment.
Changes of this file is not used in this PR/change, so we should not add them here.
There was a problem hiding this comment.
how they are not used? without this changes you wouldn't see the create report button when moving expenses from Search page
There was a problem hiding this comment.
Oops, my bad, I didn't see that it is used in.
|
@parasharrajat comments addressed |
|
Thanks. Checking... |
src/libs/ReportUtils.ts
Outdated
| // Unreported transaction from OldDot can have the reportID as an empty string | ||
| const isUnreportedExpense = !transaction?.reportID || transaction?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID; | ||
|
|
||
| const isUserWorkspaceMember = getActivePolicies(allPolicies ?? {}, currentUserEmail).length; |
There was a problem hiding this comment.
This does not check for paid policies so we need to check for that too.
|
I see that this PR is enabling create report option for expense reports as well. is this expected/ @koko57 03.10.2025_15.38.40_REC.mp4 |
|
BUG: In test 2 and 3, user does not move to created report after expense are moved. it stays on reports page. on staging, user remain on reports page for both |
I will check it |
|
I think it would be hard to differentiate - I would need to check if all the selected transactions and this is what I have So I guess I would need much coplex logix to check if only unreported transactions are selected @cristipaval can we ship with this button on the Search Page only? We're eventually adding the support for reported expenses in the next PR |
Thanks for double-checking the expected behavior, @parasharrajat! Yes, as long as it behaves correctly, let it be enabled for reported expenses as well. So we always want the Create Report as an option for the |
|
@parasharrajat are you sure that for test 2 and 3? it only navigates to the report when selecting the workspace from the selector, I will block that |
|
user should now stay on Reports Page after all the actions |
I think we can check for reports sub tab as reports sub tab does not show unreported expenses.. If that is selected do you show create Report in Move expense. @koko57 |
@parasharrajat not sure, but anyway @cristipaval said that it is expected - we want the button for both reported and unreported |
|
Sure, I will check that too. Can you please add that flow in your test steps as well? |
|
@parasharrajat done! ready for the review |
|
@parasharrajat such a note will do? I don't want to repeat all the steps 😅 |
|
May be just add notes under all cases that should work with reported one. You can say to repeat steps in the note. |
|
Bug: The Report expenses does not show create report button on Move expenses.
|
@parasharrajat thanks for pointing this out - I guess this is because we're enabling moving expenses from the search page - the option you mention will come in the second PR if you start from the expense report you're redirected to a different page |
|
When I open a report from reports page too, I don't this option.
Ok, thanks for confirming. Should we add a note on the test steps so that QA does not report it as a bug? |
can you show me a recording? with a visible url? or give me exact test steps? |
|
Here is the vid. Steps;
03.10.2025_21.46.32_REC.mp4 |
Screenshots🔲 iOS / native03.10.2025_21.32.10_REC.mp4🔲 iOS / Safari03.10.2025_21.51.19_REC.mp4🔲 MacOS / Desktop03.10.2025_21.42.15_REC.mp4🔲 MacOS / Chrome03.10.2025_20.59.58_REC.mp4🔲 Android / Chrome03.10.2025_21.22.18_REC.mp4🔲 Android / native03.10.2025_21.20.06_REC.mp403.10.2025_21.15.41_REC.mp4 |
parasharrajat
left a comment
There was a problem hiding this comment.
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 Issuessection 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
Testssection - I verified the steps for Staging and/or Production testing are in the
QA stepssection - 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 verified the steps for local testing are in the
- 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 tests pass on all platforms & I tested again on:
- Android: Native
- Android: mWeb Chrome
- iOS: Native
- 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 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.
toggleReportand notonIconClick). - I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g.
myBool && <MyComponent />. - 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 approved by marketing by adding the
Waiting for Copylabel for a copy review on the original GH to get the correct copy. - 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
- 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.
- 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 usingAvatarhave 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.js 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
thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor) - Any internal methods bound to
thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick) - 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
Avataris modified, I verified thatAvataris 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 form input styles:
- I verified that all the inputs inside a form are aligned with each other.
- I added
Designlabel so the design team can review the changes.
- If a new page is added, I verified it's using the
ScrollViewcomponent to make it scrollable when more elements are added to the page. - If the
mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps. - I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.
🎀 👀 🎀 C+ reviewed
yeah, exactly - the url is edit/submit/report later - it's handled in the second PR but actually funny that it navigates there not to the search/move-expenses |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/cristipaval in version: 9.2.24-0 🚀
|
|
🚀 Deployed to staging by https://github.com/cristipaval in version: 9.2.26-0 🚀
|
|
🚀 Deployed to production by https://github.com/lakchote in version: 9.2.26-7 🚀
|


Explanation of Change
Fixed Issues
$ #68995
PROPOSAL:
Tests
If the user has no group workspace at all --> Don't show the Move Expenses option
Prerequisites: user has no workspace, has selfDM
If the user has a default group workspace --> Show the option and create the report in the active policy
Prerequisites: user has a default workspace, has selfDM
NOTE: Create Report button should also appear when moving reported expenses and should work the same way as for unreported expenses
-> Repeat each step from the test steps above but this time select reported expenses
If the user doesn't have an active workspace but has only one group workspace --> Show the option and create the report in that workspace
Prerequisites: user has only one workspace (is the owner or invitee), has selfDM
NOTE: Create Report button should also appear when moving reported expenses and should work the same way as for unreported expenses
-> Repeat each step from the test steps above but this time select reported expenses
If the user has no active workspace but has multiple group policies --> Show the option and ask the user to pick the workspace where the new report should be created
Prerequisites: user has several workspaces - NONE OF THEM DEFAULT (delete or leave the default policy), has selfDM
NOTE: Create Report button should also appear when moving reported expenses and should work the same way as for unreported expenses
-> Repeat each step from the test steps above but this time select reported expenses
Offline tests
n/a
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
Screen.Recording.2025-10-02.at.16.16.28.mp4
Screen.Recording.2025-10-02.at.16.15.08.mp4
Screen.Recording.2025-10-02.at.16.13.18.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2025-10-02.at.15.51.51.mp4
Screen.Recording.2025-10-02.at.15.50.21.mp4
Screen.Recording.2025-10-02.at.15.44.40.mp4
MacOS: Desktop