Skip to content

[Due for payment 2026-06-19] Invoices - Invoice report field is deleted after deleting non-invoice report field #93232

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.4.5-0
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #73887
Email or phone of affected tester (no customers): odjosdjosjnojdiosj@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.5 / Chrome
App Component: Workspace Settings

Action Performed:

Precondition:

  • Enable Invoices in workspace settings.
  1. Go to staging.new.expensify.com
    2 Go to workspace settings > Invoices.
  2. Enable Invoice fields and upgrade workspace if needed.
  3. Click Add field.
  4. Create a text report field.
  5. Go to workspace settings > Reports.
  6. Enable Report fields.
  7. Create a text report field, then delete it.
  8. Go to workspace settings > Invoices.

Expected Result:

Invoice report field will remain unaffected after deleting non-invoice report field.

Actual Result:

Invoice report field is deleted after deleting non-invoice report field.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome Safari

Screenshots/Videos

Bug7177424_1781135480579.6.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Mita Rachim
Bug ID: 7177424

Activity

  1. applause-bot commented on Jun 11, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/10ba6f3d05cb69d8868e10a9573dfb1df3643ff284af1a673fdd4dfa66a21adf

  2. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 11, 2026
  3. melvin-bot commented on Jun 11, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #73887

  4. melvin-bot commented on Jun 11, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  5. github-actions commented on Jun 11, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. MelvinBot commented on Jun 11, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    Report fields and invoice fields are stored together in the policy's fieldList, but deleteReportFields builds the API payload from only the same-target remaining fields and sends that as the new complete list. The backend then overwrites fieldList with that partial list, silently dropping the fields of the other target.

    When you delete a non-invoice (expense) report field, isInvoiceField is false, so the else branch sends reportFields: JSON.stringify(remainingExpenseFields). remainingExpenseFields is filtered to exclude invoice-target fields, so the invoice field is omitted from the payload and gets deleted server-side.

    The optimistic Onyx data only marks the targeted key for deletion, which is why the invoice field disappears after the server response, not immediately.

    Why this is the cause + symmetric bug
    // ReportField.ts:368-380
    const updatedReportFieldsValues = Object.values(updatedReportFields);
    const remainingInvoiceFields = updatedReportFieldsValues.filter((f) => f.target === INVOICE);
    const remainingExpenseFields = updatedReportFieldsValues.filter((f) => !f.target || f.target === EXPENSE);
    const parameters = isInvoiceField
        ? {policyID, invoiceFields: JSON.stringify(remainingInvoiceFields)}   // drops expense fields
        : {policyID, reportFields: JSON.stringify(remainingExpenseFields)};   // drops invoice fields  ← reported bug

    The reverse path has the same defect: deleting an invoice field sends only remainingInvoiceFields, which would drop the expense report fields. The bug report only exercised one direction.

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

    The delete payload should preserve all remaining fields regardless of target, instead of filtering to the deleted field's target. Build the payload from the full set of remaining fields (updatedReportFieldsValues) so neither invoice nor expense fields are lost when the backend rewrites fieldList. The command/param name (reportFields vs invoiceFields) can still be chosen based on isInvoiceField, but the value passed should be the complete remaining list.

    What alternative solutions did you explore? (Optional)

    Make the backend DELETE_POLICY_REPORT_FIELD / DELETE_POLICY_INVOICE_FIELD commands target-aware (merge by ID rather than full overwrite). This is more robust but lives in the backend (Web-Expensify, not in this repo), so an internal engineer would need to confirm/own it. The App-side payload fix above is the minimal change to unblock the deploy.

    Confidence: Medium-High. Code evidence is conclusive for the App-side payload omission. The one assumption is that the backend overwrites fieldList with the provided list — which the reported symptom strongly confirms. Introduced by #73887 (the invoice fields feature).


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/93232) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.

  7. melvin-bot commented on Jun 11, 2026

    @melvin-bot

    ⚠️ 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.

  8. melvin-bot commented on Jun 11, 2026

    @melvin-bot

    ⚠️ 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.

  9. melvin-bot commented on Jun 11, 2026

    @melvin-bot

    ⚠️ 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.

  10. mollfpr commented on Jun 11, 2026

    @mollfpr
    Contributor

    Closing — the invoice fields feature has been reverted, so this no longer reproduces on staging.

  11. changed the title [-]Invoices - Invoice report field is deleted after deleting non-invoice report field[/-] [+][Due for payment 2026-06-19] Invoices - Invoice report field is deleted after deleting non-invoice report field[/+] on Jun 12, 2026
  12. melvin-bot commented on Jun 12, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.4.6-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 2026-06-19. 🎊

  13. melvin-bot commented on Jun 12, 2026

    @melvin-bot

    @mollfpr 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]. If no checklist is needed for this issue, you can click: [no checklist button]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2Engineering

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions