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

[$250] Held expense - No option to hold expense if an empty report is created first #58489

Open
8 tasks done
vincdargento opened this issue Mar 14, 2025 · 5 comments
Open
8 tasks done
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 Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@vincdargento
Copy link

vincdargento commented Mar 14, 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.13-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Yes, reproducible on both
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
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:

  • User is invited to a workspace, which is also the default workspace.
  1. Go to staging.new.expensify.com
  2. Go to FAB > Create report.
  3. Go back to Inbox.
  4. Click on the empty report.
  5. Submit two expenses.
  6. Go to transaction thread of any expense.
  7. Click on the report header.

Expected Result:

Hold option should be present.

Actual Result:

Hold option is not present.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

bug.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021901530553508755813
  • Upwork Job ID: 1901530553508755813
  • Last Price Increase: 2025-03-17
Issue OwnerCurrent Issue Owner: @abdulrahuman5196
@vincdargento vincdargento added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Mar 14, 2025
Copy link

melvin-bot bot commented Mar 14, 2025

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

@VictoriaExpensify
Copy link
Contributor

Hmm yeah we should fix that.

@VictoriaExpensify VictoriaExpensify added the External Added to denote the issue can be worked on by a contributor label Mar 17, 2025
Copy link

melvin-bot bot commented Mar 17, 2025

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

@melvin-bot melvin-bot bot changed the title Held expense - No option to hold expense if an empty report is created first [$250] Held expense - No option to hold expense if an empty report is created first Mar 17, 2025
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 17, 2025
Copy link

melvin-bot bot commented Mar 17, 2025

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

@nkdengineer
Copy link
Contributor

Proposal

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

Hold option is not present.

What is the root cause of that problem?

  1. When we create the new expense report, the optimistic report preview isn't created correctly, the reportActionID here is the reportActionID of the created action of the expense report.

App/src/libs/actions/Report.ts

Lines 2490 to 2494 in 703cdf4

{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReport?.reportID}`,
value: {[reportActionID]: optimisticReportPreview},
},

App/src/libs/actions/Report.ts

Lines 2530 to 2534 in 703cdf4

onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReport?.reportID}`,
value: {[reportActionID]: {pendingAction: null}},
},
];

  1. The backend returns another REPORTPREVIEW action with actorAccountID is 0

then isActionOwner is false, which causes the Hold option doesn't appear

App/src/libs/ReportUtils.ts

Lines 3752 to 3756 in 40dcff2

const isActionOwner =
typeof parentReportAction?.actorAccountID === 'number' &&
typeof currentUserPersonalDetails?.accountID === 'number' &&
parentReportAction.actorAccountID === currentUserPersonalDetails?.accountID;
const isApprover = isMoneyRequestReport(moneyRequestReport) && moneyRequestReport?.managerID !== null && currentUserPersonalDetails?.accountID === moneyRequestReport?.managerID;

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

  1. Update the optimistic data with correct reportActionID of report preview action
{
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReport?.reportID}`,
    value: {[reportPreviewActionID]: optimisticReportPreview},
},

App/src/libs/actions/Report.ts

Lines 2490 to 2494 in 703cdf4

{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReport?.reportID}`,
value: {[reportActionID]: optimisticReportPreview},
},

{
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReport?.reportID}`,
    value: {[reportPreviewActionID]: {pendingAction: null}},
},

App/src/libs/actions/Report.ts

Lines 2530 to 2534 in 703cdf4

onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReport?.reportID}`,
value: {[reportActionID]: {pendingAction: null}},
},
];

We also need to update the report preview action with the correct data:

const optimisticReportPreview: ReportAction = {
    // action: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW,
    ....
    originalMessage: {
        linkedReportID: reportID
    },
};

const optimisticReportPreview = {

2. We should add a new param reportPreviewActionID and add the reportActionID of the new optimistic report preview action to the CreateAppReport API. Then from the backend, we use it to generate a new report preview action and return the correct actorAccountID that is the current user does this API.

{reportName, type: CONST.REPORT.TYPE.EXPENSE, policyID, reportID: optimisticReportID, reportActionID},

with this, we can generate the reportPreviewActionID in createNewReport and pass it to buildNewReportOptimisticData function

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

Add test to verify that createNewReport add the correct optimistic data of expense report, report preview action.

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.

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 Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
Status: No status
Development

No branches or pull requests

4 participants