Skip to content

[Due for payment 2025-05-28] [$250] Can't add expense to processing report with delay submissions #58287

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

Open
1 of 8 tasks
m-natarajan opened this issue Mar 12, 2025 · 50 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

@m-natarajan
Copy link

m-natarajan commented Mar 12, 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.12-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
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: @joekaufmanexpensify
Slack conversation (hyperlinked to channel name): @Expensify Bugs

Action Performed:

  1. Create a workspace in NewDot.
  2. Verify delay submissions are enabled.
  3. Create an expense.
  4. Submit the report.
  5. Click into the report.
  6. Click the report create button.

Expected Result:

You should see the option to create an expense on the processing report. This is possible with delay submissions in OldDot.

Note: this should only apply to expenses you manually attempt to add to a specific report. If you create a new expense that is auto-reported (or email an expense in), it still should not be auto-reported to a processing report with delayed submit after these changes.

Actual Result:

You don't see an option to add an expense to a processing report with delay submissions. Option available on same report in OldDot

Workaround:

Unknown

Platforms:

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

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

Screenshots/Videos

Add any screenshot/video evidence
2025-03-12_09-26-36.mp4
Recording.1047.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021901586876650156357
  • Upwork Job ID: 1901586876650156357
  • Last Price Increase: 2025-03-31
  • Automatic offers:
    • DylanDylann | Reviewer | 106742893
    • daledah | Contributor | 106742894
Issue OwnerCurrent Issue Owner: @laurenreidexpensify
@m-natarajan m-natarajan added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Mar 12, 2025
Copy link

melvin-bot bot commented Mar 12, 2025

Triggered auto assignment to @laurenreidexpensify (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 Mar 12, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-03-19 07:18:21 UTC.

Proposal

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

You don't see an option to add an expense to a processing report with delay submissions. Option available on same report in OldDot

What is the root cause of that problem?

When checking if current report can add expense, we have a chain of logics:

App/src/libs/ReportUtils.ts

Lines 7669 to 7673 in eaf171e

if (canRequestMoney(report, policy, otherParticipants)) {
options = [...options, CONST.IOU.TYPE.SUBMIT];
if (!filterDeprecatedTypes) {
options = [...options, CONST.IOU.TYPE.REQUEST];
}

App/src/libs/ReportUtils.ts

Lines 7597 to 7600 in eaf171e

if (isMoneyRequestReport(report)) {
const canAddTransactions = canAddTransaction(report);
return isReportInGroupPolicy(report) ? isOwnPolicyExpenseChat && canAddTransactions : canAddTransactions;
}

App/src/libs/ReportUtils.ts

Lines 2135 to 2137 in 6286ab0

if (isReportInGroupPolicy(moneyRequestReport) && isProcessingReport(moneyRequestReport) && !isInstantSubmitEnabled(getPolicy(moneyRequestReport?.policyID))) {
return false;
}

with

App/src/libs/PolicyUtils.ts

Lines 457 to 459 in 6286ab0

function isInstantSubmitEnabled(policy: OnyxInputOrEntry<Policy> | SearchPolicy): boolean {
return policy?.autoReporting === true && policy?.autoReportingFrequency === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT;
}

If delayed submission is enabled and frequency is not "instant" the logics will return false and Create expense option is not shown.

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

Create a util function in PolicyUtils to check if Delayed Submissions are enabled

function isDelayedSubmissionsEnabled(policy: OnyxInputOrEntry<Policy>): boolean {
    return policy?.autoReporting === true && getCorrectedAutoReportingFrequency(policy) !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT;
}

Then we can modify the logics to return true if delayed submissions is enabled

App/src/libs/ReportUtils.ts

Lines 2135 to 2137 in eaf171e

if (isReportInGroupPolicy(moneyRequestReport) && isProcessingReport(moneyRequestReport) && !isInstantSubmitEnabled(getPolicy(moneyRequestReport?.policyID))) {
return false;
}

    if (isReportInGroupPolicy(moneyRequestReport) && isProcessingReport(moneyRequestReport) && isDelayedSubmissionsEnabled(getPolicy(moneyRequestReport?.policyID))) {
        return true;
    }

Tested locally and I think BE already handled this case well so we don't need any changes

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

We can adđ more test cases considering delayed submissions to existing getMoneyRequestOptions test here:

describe('getMoneyRequestOptions', () => {

What alternative solutions did you explore? (Optional)

Or we can delete this logic:

App/src/libs/ReportUtils.ts

Lines 2135 to 2137 in eaf171e

if (isReportInGroupPolicy(moneyRequestReport) && isProcessingReport(moneyRequestReport) && !isInstantSubmitEnabled(getPolicy(moneyRequestReport?.policyID))) {
return false;
}

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.

@joekaufmanexpensify
Copy link
Contributor

Added a note to the expected result section from this discussion. The changes here should only apply to an expense you manually attempt to add to a processing report with delayed submissions. A new expense you create outside of a report (either manually or by emailing in) should still not be auto-reported to a processing report with delayed submissions, same as now.

cc @trjExpensify

@melvin-bot melvin-bot bot added the Overdue label Mar 17, 2025
@laurenreidexpensify laurenreidexpensify 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/~021901586876650156357

@melvin-bot melvin-bot bot changed the title Can't add expense to processing report with delay submissions [$250] Can't add expense to processing report with delay submissions 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 - @DylanDylann (External)

@melvin-bot melvin-bot bot removed the Overdue label Mar 17, 2025
@dylanexpensify dylanexpensify moved this to Bugs and Follow Up Issues in #expensify-bugs Mar 18, 2025
@DylanDylann
Copy link
Contributor

@daledah Could you take a look at this requirement?

@daledah
Copy link
Contributor

daledah commented Mar 24, 2025

A new expense you create outside of a report (either manually or by emailing in) should still not be auto-reported to a processing report with delayed submissions

I'm not sure if the option to email in expenses even exists in ND yet. With manually option, I interpret it as "Create expense using global create button", then we already handle the new expense would be auto-reported to any unsubmitted report or create new report if there are none.

@melvin-bot melvin-bot bot added the Overdue label Mar 24, 2025
@trjExpensify
Copy link
Contributor

I'm not sure if the option to email in expenses even exists in ND yet.

Yeah, it does. Forward a receipt to [email protected] and it'll get reported on your default workspace.

With manually option, I interpret it as "Create expense using global create button",

Yeah, creating an expense anywhere other than from the menu inside the processing report directly (e.g global create, the workspace chat create menu, forwarding a receipt to receipts@).

Copy link

melvin-bot bot commented Mar 24, 2025

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@daledah
Copy link
Contributor

daledah commented Mar 25, 2025

@trjExpensify Can we test receipt forwarding using test accounts/test environments? If not, is there a way I can test this feature to update the proposal if needed?

Copy link

melvin-bot bot commented Mar 25, 2025

@DylanDylann Eep! 4 days overdue now. Issues have feelings too...

@trjExpensify
Copy link
Contributor

I'm not sure, you can ask in #expensify-open-source. Minimally though, you should be able to test in dev the global create > create expense flow. Also, the workspace chat > create expense flow.

@daledah
Copy link
Contributor

daledah commented Mar 26, 2025

@trjExpensify I tested with those flows and it should work fine without changes required.

Copy link

melvin-bot bot commented Mar 26, 2025

@laurenreidexpensify @DylanDylann this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@trjExpensify
Copy link
Contributor

Cool, @DylanDylann you happy to move this on to a secondary review of the proposal?

Copy link

melvin-bot bot commented Mar 27, 2025

@DylanDylann Still overdue 6 days?! Let's take care of this!

@DylanDylann
Copy link
Contributor

Checking again now

@melvin-bot melvin-bot bot removed the Overdue label Mar 27, 2025
@daledah
Copy link
Contributor

daledah commented Apr 16, 2025

@cristipaval While implementing the PR I discovered a BE bug, commented here

More info on this Bug:

Steps here:

  1. Open WS chat
  2. Create an expense
  3. Go to expense report, assume the reportID is 1
  4. Submit the expense
  5. Create another expense in the processing report
  6. Go back to workspace chat
  7. Click + button, OR go back to LHN and use global create button
  8. Click Create expense
  9. Complete the expense creation flow

In step 2, after create the expense, WS chat's IOUReportID will be 1. This IOUReportID is used to determine which report should a new created expense be added into.

In step 4, after submitting expense, WS chat's IOUReportID will be null. This means creating new expense from WS chat + button or FAB will create a new report

In step 5, after create a new expense in the processing report, BE sends IOUReportID is 1, which is incorrect.

In step 6, in small screen we don't call another OpenReport (because using back button in header doesn't trigger one) so IOUReportID is not reset to correct value (null in this case), so new created expense is still added into the processing report.

We need a BE fix to return IOUReportID: null when creating expense in step 5.

@cristipaval
Copy link
Contributor

@daledah thanks for raising this issue. Does this bug block the current PR?

I wonder if we could open a new issue and make it internal

@daledah
Copy link
Contributor

daledah commented Apr 17, 2025

I think it does, because the bug is only reproduced within the PR changes, so it would be counted as a regression from my PR. cc @DylanDylann for second opinion here.

@cristipaval
Copy link
Contributor

ah, I see, I'll see if I can have a look today in the backend bug

@laurenreidexpensify
Copy link
Contributor

@cristipaval did you get to look at all here?

@cristipaval
Copy link
Contributor

No, the Reviewing label confused me, and I misstook another issue with this one. The same @daledah needed another BE fix there as well 😅

@cristipaval cristipaval removed the Reviewing Has a PR in review label Apr 25, 2025
@cristipaval
Copy link
Contributor

cristipaval commented Apr 30, 2025

@daledah I investigated this, and what I found is that when the App hits the SubmitReport command, the backend doesn't send null for iouReportID, but the App optimistically sets it to null.

So, I think we should fix 2 things:

  1. BE should send onyx updates with iouReportID: null when the report is submitted
  2. BE should NOT send value updates for the iouReportID when an expense is created to an already submitted expense.

Could you please confirm? 🙏

@daledah
Copy link
Contributor

daledah commented May 2, 2025

@cristipaval Sorry for the delay, I believe these changes are correct to fix the issue.

@melvin-bot melvin-bot bot added the Overdue label May 9, 2025
@cristipaval
Copy link
Contributor

I have a WIP PR. I hope it will be ready for review today

@melvin-bot melvin-bot bot removed the Overdue label May 9, 2025
@cristipaval
Copy link
Contributor

The PR is in review.

@cristipaval
Copy link
Contributor

@daledah, the backend should be fixed. Could you please test?

@daledah
Copy link
Contributor

daledah commented May 14, 2025

@cristipaval The bug is fixed 👍

Copy link

melvin-bot bot commented May 20, 2025

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@melvin-bot melvin-bot bot added the Overdue label May 21, 2025
@cristipaval
Copy link
Contributor

cristipaval commented May 21, 2025

Hmm. I think the automation failed to apply the Reviewing label and add the payment summary because I forgot to make @daledah the issue's owner.

Here's the current status:

@melvin-bot melvin-bot bot removed the Overdue label May 21, 2025
@daledah
Copy link
Contributor

daledah commented May 21, 2025

@cristipaval I don't think it should be a regression, because IIRC the change reports feature come after this issue and PR is created. cc @DylanDylann

@cristipaval
Copy link
Contributor

ah yes, I agree 👍

it is also out of the original scope of the issue. If you don't mind, I'll keep you assigned to that issue anyway, given that you already have context.

@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 21, 2025
@melvin-bot melvin-bot bot changed the title [$250] Can't add expense to processing report with delay submissions [Due for payment 2025-05-28] [$250] Can't add expense to processing report with delay submissions May 21, 2025
Copy link

melvin-bot bot commented May 21, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.47-6 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-28. 🎊

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

Copy link

melvin-bot bot commented May 21, 2025

@DylanDylann @laurenreidexpensify @DylanDylann 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]

@laurenreidexpensify
Copy link
Contributor

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:

  • [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:

  • [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.

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

    Link to issue:

Regression Test Proposal

Precondition:

Test:

Do we agree 👍 or 👎

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels May 28, 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
Status: Bugs and Follow Up Issues
Development

No branches or pull requests

7 participants