Skip to content

[Due for payment 2025-05-14] [$250] Expense Reports - Total amount in report header does not update after editing expense amount #61070

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
8 of 16 tasks
lanitochka17 opened this issue Apr 29, 2025 · 16 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

@lanitochka17
Copy link

lanitochka17 commented Apr 29, 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.33-3
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: #60694
Email or phone of affected tester (no customers): [email protected]
**Issue reported by:**n Applause - Internal Team

Action Performed:

Precondition:

  • Log in with Expensifail account
  1. Go to staging.new.expensify.com
  2. Go to 1:1 DM
  3. Submit two expenses in 1:1 DM
  4. Go to Reports
  5. Go to Expense Reports
  6. Click on the expense report from Step 3
  7. Click on any transaction
  8. Click Amount
  9. Edit amount and save it
  10. Close the RHP

Expected Result:

The total amount in the report header "x owes amount" will update to the latest amount

Actual Result:

The total amount in report header does not update after editing expense amount

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop
Platforms Tested: On which of our officially supported platforms was this issue tested:
  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Bug6816274_1745922134381.20250429_181844.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021917276610174945314
  • Upwork Job ID: 1917276610174945314
  • Last Price Increase: 2025-04-29
Issue OwnerCurrent Issue Owner: @garrettmknight
@lanitochka17 lanitochka17 added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Apr 29, 2025
Copy link

melvin-bot bot commented Apr 29, 2025

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

@etCoderDysto
Copy link
Contributor

etCoderDysto commented Apr 29, 2025

Proposal

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

Expense Reports - Total amount in report header does not update after editing expense amount

What is the root cause of that problem?

When the if condition below holds to be true, we use cached report name that is stored in attributes[report.reportID].reportName as report title.

App/src/libs/ReportUtils.ts

Lines 4607 to 4613 in d391099

const canUseDerivedValue = report && policy === undefined && parentReportActionParam === undefined && personalDetails === undefined && invoiceReceiverPolicy === undefined;
const attributes = reportAttributesParam ?? reportAttributes;
const derivedNameExists = report && !!attributes?.[report.reportID]?.reportName;
if (canUseDerivedValue && derivedNameExists) {
return attributes[report.reportID].reportName;
}
return getReportNameInternal({report, policy, parentReportActionParam, personalDetails, invoiceReceiverPolicy});

And the cached reportName gets updated when we update the amount (ONYXKEYS.DERIVED.REPORT_ATTRIBUTES value is change is detected) below

App/src/libs/ReportUtils.ts

Lines 1043 to 1049 in d391099

Onyx.connect({
key: ONYXKEYS.DERIVED.REPORT_ATTRIBUTES,
callback: (value) => {
if (!value) {
return;
}
reportAttributes = value.reports;

But the title on report header won't be updated since we are not calling getReportName after the cached reportName is updated

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

We should pass personalDetails as forth argument so that we can recalculate report title here every time total amount changes rather than using cached reportName

const title = getReportName(report, undefined, undefined, undefined, invoiceReceiverPolicy);

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

N/A - U/I issue

What alternative solutions did you explore? (Optional)

@bernhardoj
Copy link
Contributor

Proposal

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

The expense report header title doesn't change when the report total is updated.

What is the root cause of that problem?

We get the report name from reportAttributes since only report param is available (not undefined).

const title = getReportName(report, undefined, undefined, undefined, invoiceReceiverPolicy);

App/src/libs/ReportUtils.ts

Lines 4606 to 4613 in d9c8c32

// Check if we can use report name in derived values - only when we have report but no other params
const canUseDerivedValue = report && policy === undefined && parentReportActionParam === undefined && personalDetails === undefined && invoiceReceiverPolicy === undefined;
const attributes = reportAttributesParam ?? reportAttributes;
const derivedNameExists = report && !!attributes?.[report.reportID]?.reportName;
if (canUseDerivedValue && derivedNameExists) {
return attributes[report.reportID].reportName;
}
return getReportNameInternal({report, policy, parentReportActionParam, personalDetails, invoiceReceiverPolicy});

reportAttributes will be updated when the deps change.

dependencies: [
ONYXKEYS.COLLECTION.REPORT,
ONYXKEYS.NVP_PREFERRED_LOCALE,
ONYXKEYS.PERSONAL_DETAILS_LIST,
ONYXKEYS.COLLECTION.TRANSACTION,
ONYXKEYS.COLLECTION.REPORT_ACTIONS,
ONYXKEYS.COLLECTION.POLICY,
ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS,
ONYXKEYS.COLLECTION.REPORT_METADATA,
],
compute: (dependencies, {currentValue, sourceValues}) => {
const areAllDependenciesSet = [...dependencies].every((dependency) => dependency !== undefined);
if (!areAllDependenciesSet) {
return {
reports: {},
locale: null,
};
}
const [reports, preferredLocale] = dependencies;
// if the preferred locale has changed, reset the isFullyComputed flag
if (preferredLocale !== currentValue?.locale) {
isFullyComputed = false;
}
const reportUpdates = sourceValues?.[ONYXKEYS.COLLECTION.REPORT];
const reportMetadataUpdates = sourceValues?.[ONYXKEYS.COLLECTION.REPORT_METADATA];
// if we already computed the report attributes and there is no new reports data, return the current value
if ((isFullyComputed && reportUpdates === undefined && reportMetadataUpdates === undefined) || !reports) {
return currentValue ?? {reports: {}, locale: null};
}
let dataToIterate: Record<string, Report | ReportMetadata | undefined> = reports;
if (isFullyComputed) {
if (reportUpdates) {
dataToIterate = reportUpdates;
} else if (reportMetadataUpdates) {
dataToIterate = reportMetadataUpdates;
}
}
const reportAttributes = Object.keys(dataToIterate).reduce<ReportAttributesDerivedValue['reports']>((acc, key) => {
// source value sends partial data, so we need an entire report object to do computations
const report = reports[`${ONYXKEYS.COLLECTION.REPORT}${key.replace(ONYXKEYS.COLLECTION.REPORT, '').replace(ONYXKEYS.COLLECTION.REPORT_METADATA, '')}`];
if (!report || !isValidReport(report)) {
return acc;
}
acc[report.reportID] = {
reportName: generateReportName(report),
};
return acc;
}, currentValue?.reports ?? {});
// mark the report attributes as fully computed after first iteration to avoid unnecessary recomputations on all objects
if (reportUpdates === undefined && Object.keys(reports ?? {}).length > 0 && !isFullyComputed) {
isFullyComputed = true;
}
return {
reports: reportAttributes,
locale: preferredLocale ?? null,
};
},

However, even though reportAttributes is updated, it won't trigger a re-render since we don't subscribe to it.

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

Subscribe to reportAttributes and pass it to getReportName.

const [reportAttributes] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {selector: (attributes) => attributes?.reports, canBeMissing: false});
const title = getReportName(report, undefined, undefined, undefined, invoiceReceiverPolicy, reportAttributes);

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

N/A

@garrettmknight garrettmknight added the External Added to denote the issue can be worked on by a contributor label Apr 29, 2025
@melvin-bot melvin-bot bot changed the title Expense Reports - Total amount in report header does not update after editing expense amount [$250] Expense Reports - Total amount in report header does not update after editing expense amount Apr 29, 2025
Copy link

melvin-bot bot commented Apr 29, 2025

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

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

melvin-bot bot commented Apr 29, 2025

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

@dukenv0307
Copy link
Contributor

@bernhardoj's proposal looks good to me

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Apr 30, 2025

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

@NikkiWines
Copy link
Contributor

Sorry for the delay here - agreed that @bernhardoj's proposal looks good 👍

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label May 1, 2025
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels May 2, 2025
@bernhardoj
Copy link
Contributor

PR is ready

cc: @dukenv0307

@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 7, 2025
@melvin-bot melvin-bot bot changed the title [$250] Expense Reports - Total amount in report header does not update after editing expense amount [Due for payment 2025-05-14] [$250] Expense Reports - Total amount in report header does not update after editing expense amount May 7, 2025
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 7, 2025
Copy link

melvin-bot bot commented May 7, 2025

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

Copy link

melvin-bot bot commented May 7, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.41-1 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-14. 🎊

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

  • @bernhardoj requires payment through NewDot Manual Requests
  • @dukenv0307 requires payment through NewDot Manual Requests

Copy link

melvin-bot bot commented May 7, 2025

@dukenv0307 @garrettmknight @dukenv0307 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]

@dukenv0307
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
  • 2b. Reported on staging (deploy blocker)
  • 2c. 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/55863/files#r2078810918

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

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

Test:

  • Table report view beta is enabled
  1. Open a DM chat
  2. Create 2 money request
  3. Open the expense report
  4. Edit one of the expense amount
  5. Verify the report header title is updated

Do we agree 👍 or 👎

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels May 14, 2025
Copy link

melvin-bot bot commented May 14, 2025

Payment Summary

Upwork Job

BugZero Checklist (@garrettmknight)

  • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1917276610174945314/hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@garrettmknight
Copy link
Contributor

Request payment when you're ready!

@bernhardoj
Copy link
Contributor

Requested in ND.

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
Development

No branches or pull requests

6 participants