Skip to content

[Due for payment 2025-05-13] [$250] Expense Reports - Hold option is not present when the expenses are bulk selected #60111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
6 of 8 tasks
jponikarchuk opened this issue Apr 11, 2025 · 29 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@jponikarchuk
Copy link

jponikarchuk commented Apr 11, 2025

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.1.27-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: No, reproducible on hybrid only
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team
Device used: Mac 15.3 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Log in with Expensifail account.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Submit two expenses to the workspace chat.
  4. Go to Reports.
  5. Go to Expense Reports.
  6. Bulk select all the expenses from Step 3.
  7. Click on the dropdown.
  8. Note that Hold option is present.
  9. Click on the expense row.
  10. Bulk select all the expenses.
  11. Click on the dropdown.

Expected Result:

Hold option will be present.

Actual Result:

Hold option is not present when the expenses are bulk selected.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021911870137765075477
  • Upwork Job ID: 1911870137765075477
  • Last Price Increase: 2025-04-14
  • Automatic offers:
    • Tony-MK | Contributor | 106952936
Issue OwnerCurrent Issue Owner: @OfstadC
@jponikarchuk jponikarchuk added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Apr 11, 2025
Copy link

melvin-bot bot commented Apr 11, 2025

Triggered auto assignment to @OfstadC (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@daledah
Copy link
Contributor

daledah commented Apr 11, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-04-11 11:03:16 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Hold option is not present when the expenses are bulk selected.

What is the root cause of that problem?

We are checking the condition that selectedTransactions.length === 1 here

if (!anyTransactionOnHold && selectedTransactions.length === 1 && !isReportReimbursed) {
options.push({
text: translate('iou.hold'),
icon: Expensicons.Stopwatch,
value: CONST.REPORT.SECONDARY_ACTIONS.HOLD,
onSelected: () => {
if (!moneyRequestReport?.reportID) {
return;
}
Navigation.navigate(ROUTES.SEARCH_MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS.getRoute({reportID: moneyRequestReport.reportID}));
},
});
}

What changes do you think we should make in order to solve the problem?

We should remove selectedTransactions.length === 1 in this condition

     if (!anyTransactionOnHold && !isReportReimbursed) {
            options.push({
                text: translate('iou.hold'),
                icon: Expensicons.Stopwatch,
                value: CONST.REPORT.SECONDARY_ACTIONS.HOLD,
                onSelected: () => {
                    if (!moneyRequestReport?.reportID) {
                        return;
                    }
                    Navigation.navigate(ROUTES.SEARCH_MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS.getRoute({reportID: moneyRequestReport.reportID}));
                },
            });
        }

if (!anyTransactionOnHold && selectedTransactions.length === 1 && !isReportReimbursed) {
options.push({
text: translate('iou.hold'),
icon: Expensicons.Stopwatch,
value: CONST.REPORT.SECONDARY_ACTIONS.HOLD,
onSelected: () => {
if (!moneyRequestReport?.reportID) {
return;
}
Navigation.navigate(ROUTES.SEARCH_MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS.getRoute({reportID: moneyRequestReport.reportID}));
},
});
}

We should do the same of the unhold options

And we should use holdMoneyRequestOnSearch API when we choose the multiple transaction

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

None

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

@Tony-MK
Copy link
Contributor

Tony-MK commented Apr 11, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-04-11 22:55:00 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Expense Reports - Hold option is not present when the expenses are bulk selected

What is the root cause of that problem?

The selectedTransactions.length === 1 condition prevents the hold from being displayed.

const selectedTransactions = selectedTransactionsID.map((transactionID) => getTransaction(transactionID)).filter((t) => !!t);
const anyTransactionOnHold = selectedTransactions.some(isOnHoldTransactionUtils);
const allTransactionOnHold = selectedTransactions.every(isOnHoldTransactionUtils);
const isReportReimbursed = moneyRequestReport?.stateNum === CONST.REPORT.STATE_NUM.APPROVED && moneyRequestReport?.statusNum === CONST.REPORT.STATUS_NUM.REIMBURSED;
if (!anyTransactionOnHold && selectedTransactions.length === 1 && !isReportReimbursed) {
options.push({
text: translate('iou.hold'),

What changes do you think we should make in order to solve the problem?

I believe the best solution is to replace the selectedTransactions.length === 1 condition with a better condition by checking if all the selected transactions can be held or unheld.

This allows us to delete both !anyTransactionOnHold and allTransactionOnHold.

if (!anyTransactionOnHold && selectedTransactions.length === 1 && !isReportReimbursed) {

So let's use the ReportUtils.canHoldUnholdReportAction function to help to implement the two conditions below.

const canHoldAllTransactions = selectedTransactions.every((transaction) => {
   return canHoldUnholdReportAction(getIOUActionForTransactionID(reportActions, transaction?.transactionID)).canHoldRequest
})

...

if (canHoldAllTransactions && !isReportReimbursed) {

if (allTransactionOnHold && selectedTransactions.length === 1) {

const canUnHoldAllTransactions = selectedTransactions.every((transaction) => {
   return canHoldUnholdReportAction(getIOUActionForTransactionID(reportActions, transaction?.transactionID)).canUnHoldRequest
})

...

if (canUnHoldAllTransactions) {

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

N/A

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

N/A

@melvin-bot melvin-bot bot added the Overdue label Apr 14, 2025
@OfstadC OfstadC added the External Added to denote the issue can be worked on by a contributor label Apr 14, 2025
@melvin-bot melvin-bot bot changed the title Expense Reports - Hold option is not present when the expenses are bulk selected [$250] Expense Reports - Hold option is not present when the expenses are bulk selected Apr 14, 2025
Copy link

melvin-bot bot commented Apr 14, 2025

Job added to Upwork: https://www.upwork.com/jobs/~021911870137765075477

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 14, 2025
Copy link

melvin-bot bot commented Apr 14, 2025

Triggered auto assignment to Contributor-plus team member for initial proposal review - @allroundexperts (External)

@melvin-bot melvin-bot bot removed the Overdue label Apr 14, 2025
@allroundexperts
Copy link
Contributor

allroundexperts commented Apr 16, 2025

@daledah's proposal looks good to me. I think the anyTransactionOnHold and allTransactionOnHold are sufficient to show the hold and un-hold option.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Apr 16, 2025

Triggered auto assignment to @marcaaron, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@Tony-MK
Copy link
Contributor

Tony-MK commented Apr 16, 2025

Hey @allroundexperts, I'm just curious why we shouldn't use a condition that checks if any selected transactions can not be held and vice versa.

This edge case requires this condition to prevent the hold or unhold option from showing.

Excuse me for asking, but could you explain why we shouldn't implement this condition?

Thanks

@allroundexperts
Copy link
Contributor

Because we're already checking for it when we do:

 if (!anyTransactionOnHold && selectedTransactions.length === 1 && !isReportReimbursed) { 

@Tony-MK
Copy link
Contributor

Tony-MK commented Apr 16, 2025

That condition only checks if any of the transactions are on hold.

This is for transactions that are already held.

I meant we should check if all of the transactions can or can't be held.

Do you see the difference?

@allroundexperts
Copy link
Contributor

Not sure if I am getting you, but we're checking for the second condition here already as well.

@Tony-MK
Copy link
Contributor

Tony-MK commented Apr 16, 2025

The second condition is for pushing the unhold option, which needs to be addressed together with the condition of the hold option.

However, we should change both conditions to check if all selected transactions can or can't be held because the current anyTransactionOnHold or allTransactionOnHold booleans don't provide that.

The condition for the hold option will check if all selected transactions can be held.

The condition for the unhold option will check if all selected transactions can be unheld.

@marcaaron
Copy link
Contributor

@allroundexperts can you resolve this conversation and then tag me again when we are ready to assign? Thanks!

@allroundexperts
Copy link
Contributor

@Tony-MK Why does it need to be addressed together? Sorry, but I can't seem to understand why we can't handle them separately like we are doing right now?

@Tony-MK
Copy link
Contributor

Tony-MK commented Apr 16, 2025

@Tony-MK Why does it need to be addressed together?

I mean't to say we should change both conditions and remove anyTransactionOnHold and allTransactionOnHold with new booleans canHoldAllTransactions and canUnHoldAllTransactions

@allroundexperts
Copy link
Contributor

remove anyTransactionOnHold and allTransactionOnHold with new booleans canHoldAllTransactions and canUnHoldAllTransactions

Why do we need to use new booleans? Can you please explain that as well?

@Tony-MK
Copy link
Contributor

Tony-MK commented Apr 16, 2025

We need to create new booleans because the anyTransactionOnHold and allTransactionOnHold checks if a transaction or all transactions are on hold, but not if they can be held or unheld.

For example: there will be issues when we attempt to hold the selected transactions, but one transaction can't be held and is not held.

@allroundexperts
Copy link
Contributor

@Tony-MK Can you post a screen recording of the issue you're talking about?

In my opinion, canHoldAllTransactions = !anyTransactionOnHold and canUnHoldAllTransactions = allTransactionOnHold

@Tony-MK
Copy link
Contributor

Tony-MK commented Apr 16, 2025

The OP seems to be solved, kindly check.

However, I still propose to fix the other issue shown below.

Screen.Recording.2025-04-17.at.00.10.07.mov

App/src/libs/ReportUtils.ts

Lines 3896 to 3897 in 45cd5bf

const isScanning = hasReceiptTransactionUtils(transaction) && isReceiptBeingScanned(transaction);
const isClosed = isClosedReport(moneyRequestReport);

This is one example.

The canHoldUnholdReportAction function will check if the money request is scanning and return false for canHoldRequest.

Since we are not using the canHoldUnholdReportAction function ,the hold option will be displayed.

@allroundexperts
Copy link
Contributor

I get that now @Tony-MK. Thanks for the detailed explanation. I agree that its much better to check if we can actually hold / un-hold vs just checking if the expense is held or not.

Your proposal was a better option.

@marcaaron Let's assign @Tony-MK!

@Tony-MK
Copy link
Contributor

Tony-MK commented Apr 16, 2025

Welcome 👍
PR should be ready soon.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 16, 2025
Copy link

melvin-bot bot commented Apr 16, 2025

📣 @Tony-MK 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Apr 17, 2025
@Tony-MK
Copy link
Contributor

Tony-MK commented Apr 17, 2025

Hey, @allroundexperts.

The PR is ready for review.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels May 6, 2025
@melvin-bot melvin-bot bot changed the title [$250] Expense Reports - Hold option is not present when the expenses are bulk selected [Due for payment 2025-05-13] [$250] Expense Reports - Hold option is not present when the expenses are bulk selected May 6, 2025
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 6, 2025
Copy link

melvin-bot bot commented May 6, 2025

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented May 6, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.39-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2025-05-13. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented May 6, 2025

@allroundexperts @OfstadC @allroundexperts The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels May 12, 2025
@OfstadC
Copy link
Contributor

OfstadC commented May 13, 2025

@allroundexperts please complete the BZ checklist so we can issue payment 😃

@allroundexperts
Copy link
Contributor

allroundexperts commented May 14, 2025

BugZero Checklist:

  • [Contributor] Classify the bug:
Bug classification

Source of bug:

  • 1a. Result of the original design (eg. a case wasn't considered)
  • 1b. Mistake during implementation
  • 1c. Backend bug
  • 1z. Other:

Where bug was reported:

  • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
  • 2b. Reported on staging (eg. found during regression or PR testing)
  • 2d. Reported on a PR
  • 2z. Other:

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other:
  • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

    Link to comment: https://github.com/Expensify/App/pull/59433/files#r2089848201

  • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

    Link to discussion: N/A

  • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

  • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

    Link to issue: https://github.com/Expensify/Expensify/issues/501146

Regression Test Proposal

Precondition:

  • N/A

Test:

  1. Go to workspace chat
  2. Submit two or more expenses to the workspace chat.
  3. Go to Reports.
  4. Go to Expense Reports.
  5. Click on the expense reports created in step 2.
  6. Bulk select all the expenses.
  7. Click on the dropdown menu.
  8. Verify that the hold option is present, then click it.
  9. Click on the dropdown menu again.
  10. Verify that the unhold option is present, then click it.
  11. Click on the dropdown menu again.

Verify that the hold option is present

Do we agree 👍 or 👎

@OfstadC
Copy link
Contributor

OfstadC commented May 14, 2025

Payment Summary

@OfstadC OfstadC closed this as completed May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

6 participants