Skip to content
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

[Awaiting checklist] [$250] [Held requests] 'Hold expense` option does not show in the preview overflow menu #41440

Closed
6 tasks done
m-natarajan opened this issue May 1, 2024 · 22 comments
Assignees
Labels
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

@m-natarajan
Copy link

m-natarajan commented May 1, 2024

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: 1.4.69-0
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @JmillsExpensify
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1714532350260749

Action Performed:

  1. Create one or two expenses on a Collect policy
  2. Navigate to Workspace Chat > Report
  3. Hover over an expense
  4. Click the three dots in the comment action menu

Expected Result:

Hold is an option in the comment action overflow menu

Actual Result:

Hold is not available

Workaround:

unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
CleanShot 2024-04-30 at 20 59 21@2x

Snip - (7) New Expensify (2)

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0124de9c5bfd8809b9
  • Upwork Job ID: 1786382301159866368
  • Last Price Increase: 2024-05-03
  • Automatic offers:
    • hungvu193 | Reviewer | 0
    • Krishna2323 | Contributor | 0
Issue OwnerCurrent Issue Owner: @twisterdotcom
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels May 1, 2024
Copy link

melvin-bot bot commented May 1, 2024

Triggered auto assignment to @twisterdotcom (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.

@JmillsExpensify JmillsExpensify changed the title 'Hold expense` option does not show in the preview overflow menu [Held requests] 'Hold expense` option does not show in the preview overflow menu May 1, 2024
@Krishna2323
Copy link
Contributor

Proposal

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

[Held requests] 'Hold expense` option does not show in the preview overflow menu

What is the root cause of that problem?

New feature

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

Steps we need to follow to get this feature working:

  1. Add Hold expense & Unhold expense actions in ContextMenuActions.
Code
    {
        isAnonymousAction: false,
        textTranslateKey: 'iou.unholdExpense',
        icon: Expensicons.Stopwatch,
        shouldShow: (type, reportAction) =>
            type === CONST.CONTEXT_MENU_TYPES.REPORT_ACTION && ReportUtils.canEditReportAction(reportAction) && ReportUtils.canHoldUnholdReportAction(reportAction).canUnholdRequest,
        onPress: (closePopover, {reportID, reportAction}) => {
            // const hold=ReportUtils.changeMoneyRequestHoldStatus().
            if (closePopover) {
                hideContextMenu(false, () => ReportUtils.changeMoneyRequestHoldStatus(reportAction));
                return;
            }

            // No popover to hide, call changeMoneyRequestHoldStatus immediately
            ReportUtils.changeMoneyRequestHoldStatus(reportAction);
        },
        getDescription: () => {},
    },
    {
        isAnonymousAction: false,
        textTranslateKey: 'iou.hold',
        icon: Expensicons.Stopwatch,
        shouldShow: (type, reportAction) =>
            type === CONST.CONTEXT_MENU_TYPES.REPORT_ACTION && ReportUtils.canEditReportAction(reportAction) && ReportUtils.canHoldUnholdReportAction(reportAction).canHoldRequest,
        onPress: (closePopover, {reportID, reportAction}) => {
            // const hold=ReportUtils.changeMoneyRequestHoldStatus().
            if (closePopover) {
                hideContextMenu(false, () => ReportUtils.changeMoneyRequestHoldStatus(reportAction));
                return;
            }

            // No popover to hide, call changeMoneyRequestHoldStatus immediately
            ReportUtils.changeMoneyRequestHoldStatus(reportAction);
        },
        getDescription: () => {},
    },
  1. Introduce a function canHoldUnholdReportAction in ReportUtils. This will check if the report action is a iou and can be held/unheld.
Code
function getParentReportAction(parentReportActions: ReportActions | null | undefined, parentReportActionID: string | undefined): ReportAction | null {
    if (!parentReportActions || !parentReportActionID) {
        return null;
    }
    return parentReportActions[parentReportActionID ?? '0'];
}

function canHoldUnholdReportAction(reportAction: OnyxEntry<ReportAction>): {canHoldRequest: boolean; canUnholdRequest: boolean} {
    if (reportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.IOU) {
        return {canHoldRequest: false, canUnholdRequest: false};
    }
    const moneyRequestReportID = reportAction?.originalMessage?.IOUReportID ?? 0;

    if (!moneyRequestReportID) {
        return {canHoldRequest: false, canUnholdRequest: false};
    }

    const moneyRequestReport = getReport(String(moneyRequestReportID));

    if (!moneyRequestReport) {
        return {canHoldRequest: false, canUnholdRequest: false};
    }

    const isSettled = ReportUtils.isSettled(moneyRequestReport?.reportID);
    const isApproved = ReportUtils.isReportApproved(moneyRequestReport);
    const transactionID = moneyRequestReport ? reportAction?.originalMessage?.IOUTransactionID : 0;
    const transaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`] ?? ({} as Transaction);
    const parentReportActionsKey = `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${moneyRequestReport.parentReportID}`;
    const parentReportActions = allReportActions?.[parentReportActionsKey];
    const parentReport = getReport(String(moneyRequestReport.parentReportID));
    const parentReportAction = getParentReportAction(parentReportActions, moneyRequestReport?.parentReportActionID);

    const isRequestIOU = parentReport?.type === 'iou';
    const isHoldCreator = ReportUtils.isHoldCreator(transaction, moneyRequestReport?.reportID) && isRequestIOU;
    const isTrackExpenseReport = ReportUtils.isTrackExpenseReport(moneyRequestReport);
    const isActionOwner =
        typeof parentReportAction?.actorAccountID === 'number' &&
        typeof currentUserPersonalDetails?.accountID === 'number' &&
        parentReportAction.actorAccountID === currentUserPersonalDetails?.accountID;
    const isApprover =
        ReportUtils.isMoneyRequestReport(moneyRequestReport) && moneyRequestReport?.managerID !== null && currentUserPersonalDetails?.accountID === moneyRequestReport?.managerID;
    const isOnHold = TransactionUtils.isOnHold(transaction);
    const isScanning = TransactionUtils.hasReceipt(transaction) && TransactionUtils.isReceiptBeingScanned(transaction);

    const canModifyStatus = !isTrackExpenseReport && (isPolicyAdmin || isActionOwner || isApprover);
    const isDeletedParentAction = ReportActionsUtils.isDeletedAction(parentReportAction);

    const canHoldOrUnholdRequest = !isSettled && !isApproved && !isDeletedParentAction;
    const canHoldRequest = canHoldOrUnholdRequest && !isOnHold && (isHoldCreator || (!isRequestIOU && canModifyStatus)) && !isScanning;
    const canUnholdRequest = Boolean(canHoldOrUnholdRequest && isOnHold && (isHoldCreator || (!isRequestIOU && canModifyStatus)));

    return {canHoldRequest, canUnholdRequest};
}
  1. Introduce a new function changeMoneyRequestHoldStatus in ReportUtils. This will take report action as param and will hold/unhold transaction based on current status.
Code
const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry<ReportAction>): void => {
    if (reportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.IOU) {
        return;
    }
    const moneyRequestReportID = reportAction?.originalMessage?.IOUReportID ?? 0;

    const moneyRequestReport = getReport(String(moneyRequestReportID));
    if (!moneyRequestReportID || !moneyRequestReport) {
        return;
    }

    const parentReportActionsKey = `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${moneyRequestReport.parentReportID}`;
    const parentReportActions = allReportActions?.[parentReportActionsKey];
    const parentReportAction = getParentReportAction(parentReportActions, moneyRequestReport?.parentReportActionID);
    const transactionID = moneyRequestReport ? reportAction?.originalMessage?.IOUTransactionID : 0;
    const transaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`] ?? ({} as Transaction);
    const isOnHold = TransactionUtils.isOnHold(transaction);
    const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${moneyRequestReport.policyID}`] ?? null;

    const iouTransactionID = parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? parentReportAction.originalMessage?.IOUTransactionID ?? '' : '';

    if (isOnHold) {
        IOU.unholdRequest(transactionID, reportAction.childReportID);
    } else {
        const activeRoute = encodeURIComponent(Navigation.getActiveRouteWithoutParams());
        Navigation.navigate(ROUTES.MONEY_REQUEST_HOLD_REASON.getRoute(policy?.type ?? CONST.POLICY.TYPE.PERSONAL, transactionID, reportAction.childReportID, activeRoute));
    }
};

PS: This is just a pseudo-code which will be refactored.

What alternative solutions did you explore? (Optional)

Result

hold_unhold_feat.mp4

@twisterdotcom twisterdotcom added the External Added to denote the issue can be worked on by a contributor label May 3, 2024
@melvin-bot melvin-bot bot changed the title [Held requests] 'Hold expense` option does not show in the preview overflow menu [$250] [Held requests] 'Hold expense` option does not show in the preview overflow menu May 3, 2024
Copy link

melvin-bot bot commented May 3, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label May 3, 2024
Copy link

melvin-bot bot commented May 3, 2024

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

@hungvu193
Copy link
Contributor

@Krishna2323's proposal here is straightforward 💪. LGTM!
🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented May 3, 2024

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

Copy link

melvin-bot bot commented May 7, 2024

@flodnv, @twisterdotcom, @hungvu193 Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label May 7, 2024
@hungvu193
Copy link
Contributor

bump @flodnv for final review.

@melvin-bot melvin-bot bot removed the Overdue label May 7, 2024
@trjExpensify
Copy link
Contributor

@robertjchen @marcochavezf perhaps one of you can do the secondary proposal review?

@robertjchen robertjchen assigned robertjchen and unassigned flodnv May 8, 2024
@robertjchen
Copy link
Contributor

Reviewed and agreed with @Krishna2323 's proposal 👍

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label May 8, 2024
Copy link

melvin-bot bot commented May 8, 2024

📣 @hungvu193 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented May 8, 2024

📣 @Krishna2323 🎉 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 📖

@Krishna2323
Copy link
Contributor

This requires a good amount of testing and work. I will raise PR on the weekends.

@hungvu193
Copy link
Contributor

Still working on the PR

@trjExpensify trjExpensify moved this from Polish to Release 2: Summer 2024 (Aug) in [#whatsnext] #wave-collect May 20, 2024
@hungvu193
Copy link
Contributor

Same

@robertjchen
Copy link
Contributor

One more tiny lint issue on the PR and we can merge 👍

@robertjchen
Copy link
Contributor

merged and now on staging

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jun 13, 2024
@melvin-bot melvin-bot bot changed the title [$250] [Held requests] 'Hold expense` option does not show in the preview overflow menu [HOLD for payment 2024-06-20] [$250] [Held requests] 'Hold expense` option does not show in the preview overflow menu Jun 13, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jun 13, 2024
Copy link

melvin-bot bot commented Jun 13, 2024

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

Copy link

melvin-bot bot commented Jun 13, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.82-4 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 2024-06-20. 🎊

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

Copy link

melvin-bot bot commented Jun 13, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@hungvu193] The PR that introduced the bug has been identified. Link to the PR:
  • [@hungvu193] 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:
  • [@hungvu193] A discussion in #expensify-bugs 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:
  • [@hungvu193] Determine if we should create a regression test for this bug.
  • [@hungvu193] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@twisterdotcom] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jun 19, 2024
@twisterdotcom
Copy link
Contributor

Payment Summary:

@twisterdotcom twisterdotcom removed the Awaiting Payment Auto-added when associated PR is deployed to production label Jun 20, 2024
@twisterdotcom twisterdotcom changed the title [HOLD for payment 2024-06-20] [$250] [Held requests] 'Hold expense` option does not show in the preview overflow menu [Awaiting checklist] [$250] [Held requests] 'Hold expense` option does not show in the preview overflow menu Jun 20, 2024
@hungvu193
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: No offending PR, this is a new feature rather than a bug.
  • 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: N/A
  • A discussion in #expensify-bugs 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
  • Determine if we should create a regression test for this bug: No

This is more of feature request than a bug, I don't think we should create a regression test IMO.
(https://expensify.slack.com/archives/C049HHMV9SM/p1714836774366969).

@github-project-automation github-project-automation bot moved this from Release 2: Summer 2024 (Aug) to Done in [#whatsnext] #wave-collect Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
No open projects
Archived in project
Development

No branches or pull requests

7 participants