Skip to content

[$250] Expense preview- Report title part of report preview is blank briefly after submitting expense #59525

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
5 of 8 tasks
IuliiaHerets opened this issue Apr 2, 2025 · 28 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Apr 2, 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.22-2
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: No, reproducible on hybrid only
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp #58479
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:

  • Log in with Expensifail account.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Submit a manual expense.
  4. Note that the report title part of the expense report preview is blank briefly.
  5. Click Submit.
  6. Go offline.
  7. Submit another manual expense.

Expected Result:

The report title part of the expense report preview should not be blank after submitting the expense.

Actual Result:

In offline mode, the report title part of the expense report preview is blank after submitting the expense.
In online mode, the same part is blank briefly after submitting the expense.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Image https://github.com/user-attachments/assets/32aa7967-a8b9-48b8-bc88-31b2fddf27ed

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021907791019793338504
  • Upwork Job ID: 1907791019793338504
  • Last Price Increase: 2025-04-03
  • Automatic offers:
    • nkdengineer | Contributor | 106825210
Issue OwnerCurrent Issue Owner: @Beamanator
@IuliiaHerets IuliiaHerets added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Apr 2, 2025
Copy link

melvin-bot bot commented Apr 2, 2025

Triggered auto assignment to @isabelastisser (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 Apr 2, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-04-02 10:48:29 UTC.

Proposal

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

In offline mode, the report title part of the expense report preview is blank after submitting the expense.
In online mode, the same part is blank briefly after submitting the expense.

What is the root cause of that problem?

We don't return the childReportName when we run buildOptimisticReportPreview to update Onyx data

App/src/libs/ReportUtils.ts

Lines 5953 to 5980 in 66f28d3

return {
reportActionID: reportActionID ?? rand64(),
reportID: chatReport?.reportID,
actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW,
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
originalMessage: {
linkedReportID: iouReport?.reportID,
},
message: [
{
html: message,
text: message,
isEdited: false,
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
},
],
delegateAccountID: delegateAccountDetails?.accountID,
created,
accountID: iouReport?.managerID,
// The preview is initially whispered if created with a receipt, so the actor is the current user as well
actorAccountID: hasReceipt ? currentUserAccountID : reportActorAccountID,
childReportID: childReportID ?? iouReport?.reportID,
childMoneyRequestCount: 1,
childLastActorAccountID: currentUserAccountID,
childLastMoneyRequestComment: comment,
childRecentReceiptTransactionIDs: hasReceipt && !isEmptyObject(transaction) && transaction?.transactionID ? {[transaction.transactionID]: created} : undefined,
...(isTestTransaction && {childStateNum: 2, childStatusNum: 4}),
};

It leads to action.childReportName being empty when creating an expense in offline

<Text
style={[styles.headerText]}
testID="MoneyRequestReportPreview-reportName"
>
{action.childReportName}
</Text>

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

We have some ways to fix it as follows

  1. The simplest way is that we will not show this View when there is no childReportName

  2. We can add fallback here like 'Expense report'

  1. We will calculate and return additional childReportName in buildOptimisticReportPreview by using populateOptimisticReportFormula function
  • Create a new pattern in const.ts file DEFAULT_REPORT_ID_PATTERN: '{report:type} {report:reportID}'
  • Update function populateOptimisticReportFormula to match with DEFAULT_REPORT_ID_PATTERN here
        .replaceAll('{report:reportID}', report.reportID ?? '')
  • Return childReportName in buildOptimisticReportPreview function
    const childReportName = populateOptimisticReportFormula(CONST.POLICY.DEFAULT_REPORT_ID_PATTERN, iouReport, undefined);

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

None

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.

@nkdengineer
Copy link
Contributor

Proposal

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

In offline mode, the report title part of the expense report preview is blank after submitting the expense.
In online mode, the same part is blank briefly after submitting the expense.

What is the root cause of that problem?

We're displaying the report title in report preview from childReportName of REPORTPREVIEW action,

<Text
style={[styles.headerText]}
testID="MoneyRequestReportPreview-reportName"
>
{action.childReportName}
</Text>

But childReportName is empty when we create optimistic data for REPORTPREVIEW action that leads the report title is empty briefly until the API is done.

App/src/libs/ReportUtils.ts

Lines 5953 to 5980 in 66f28d3

return {
reportActionID: reportActionID ?? rand64(),
reportID: chatReport?.reportID,
actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW,
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
originalMessage: {
linkedReportID: iouReport?.reportID,
},
message: [
{
html: message,
text: message,
isEdited: false,
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
},
],
delegateAccountID: delegateAccountDetails?.accountID,
created,
accountID: iouReport?.managerID,
// The preview is initially whispered if created with a receipt, so the actor is the current user as well
actorAccountID: hasReceipt ? currentUserAccountID : reportActorAccountID,
childReportID: childReportID ?? iouReport?.reportID,
childMoneyRequestCount: 1,
childLastActorAccountID: currentUserAccountID,
childLastMoneyRequestComment: comment,
childRecentReceiptTransactionIDs: hasReceipt && !isEmptyObject(transaction) && transaction?.transactionID ? {[transaction.transactionID]: created} : undefined,
...(isTestTransaction && {childStateNum: 2, childStatusNum: 4}),
};

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

  1. Add childReportName as iouReport.reportName here
childReportName: iouReport.reportName,

App/src/libs/ReportUtils.ts

Lines 5953 to 5980 in 66f28d3

return {
reportActionID: reportActionID ?? rand64(),
reportID: chatReport?.reportID,
actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW,
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
originalMessage: {
linkedReportID: iouReport?.reportID,
},
message: [
{
html: message,
text: message,
isEdited: false,
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
},
],
delegateAccountID: delegateAccountDetails?.accountID,
created,
accountID: iouReport?.managerID,
// The preview is initially whispered if created with a receipt, so the actor is the current user as well
actorAccountID: hasReceipt ? currentUserAccountID : reportActorAccountID,
childReportID: childReportID ?? iouReport?.reportID,
childMoneyRequestCount: 1,
childLastActorAccountID: currentUserAccountID,
childLastMoneyRequestComment: comment,
childRecentReceiptTransactionIDs: hasReceipt && !isEmptyObject(transaction) && transaction?.transactionID ? {[transaction.transactionID]: created} : undefined,
...(isTestTransaction && {childStateNum: 2, childStatusNum: 4}),
};

I noticed that we have an inconsistency for the expense report's reportName. The default report title formula is {report:type} {report:startdate}, and we used it to generate reportName in optimistic data here but the backend return the reportName with the formula is {report:type} {report:reportID}. We should fix it from backend side to change the default formula of the title field to {report:type} {report:reportID} or fix reportName of new expense report.

Image
  1. The IOU report is displaying IOU, but this report has the custom report name in front-end; then we can use getReportName(iouReport) and fallback it to action.childReportName if iouReport data isn't available
Image
{getReportName(iouReport) || action.childReportName} 

<Text
style={[styles.headerText]}
testID="MoneyRequestReportPreview-reportName"
>
{action.childReportName}
</Text>

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

Add a unit test for buildOptimisticReportPreview and verify that the childReportName is equal to iouReport.reportName.

What alternative solutions did you explore? (Optional)

NA

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.

@isabelastisser isabelastisser added 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 labels Apr 3, 2025
@melvin-bot melvin-bot bot changed the title Expense preview- Report title part of report preview is blank briefly after submitting expense [$250] Expense preview- Report title part of report preview is blank briefly after submitting expense Apr 3, 2025
Copy link

melvin-bot bot commented Apr 3, 2025

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

Copy link

melvin-bot bot commented Apr 3, 2025

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

@dylanexpensify dylanexpensify moved this to Bugs and Follow Up Issues in #expensify-bugs Apr 3, 2025
@hoangzinh
Copy link
Contributor

but the backend return the reportName with the formula is {report:type} {report:reportID}. We should fix it from backend side to change the default formula of the title field to {report:type} {report:reportID}

@nkdengineer I got confused here. Can you clarify what it means? I'm interpreting that because BE is already returning {report:type} {report:reportID}, why do we also need to change the default to {report:type} {report:reportID}?

@nkdengineer
Copy link
Contributor

nkdengineer commented Apr 4, 2025

I'm interpreting that because BE is already returning {report:type} {report:reportID}

@hoangzinh That is the report name of the expense report.

I mean, we need to fix titleReportField.defaultValue to {report:type} {report:reportID}. It's {report:type} {report:startdate} that why the expense report's reportName is different in offline.

App/src/libs/ReportUtils.ts

Lines 5411 to 5413 in 3b313d1

if (!!titleReportField && isPaidGroupPolicyExpenseReport(expenseReport)) {
expenseReport.reportName = populateOptimisticReportFormula(titleReportField.defaultValue, expenseReport, policy);
}

@hoangzinh
Copy link
Contributor

Thank you for posting proposals @daledah @nkdengineer. I think we can go with @nkdengineer's proposal, because:

  • I asked for more information here. It looks like FE should use the formula stored in policy.fieldList.text_title.defaultValue to generate an optimistic reportName, which iouReport.reportName already does.

  • Besides that, I think it's also a BE issue, it should generate reportName based on policy.fieldList.text_title.defaultValue instead of {report:type} {report:reportID}. I found that we have an issue for it already [Tracking] Custom Report Names on New Expensify #44340

Link to proposal #59525 (comment)

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Apr 4, 2025

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

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

melvin-bot bot commented Apr 7, 2025

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

@nkdengineer
Copy link
Contributor

@isabelastisser Because this issue requires BE change and we already had the issue to do that, should we hold it util BE is fixed? IMO, we can process this issue separately since we can verify it on offline mode. cc @hoangzinh

@hoangzinh
Copy link
Contributor

cc @Beamanator ^ what do you think? I think we can continue to proceed with @nkdengineer PR here. The current issue is that the Report title of report preview will have the format "Expenses yyyy-mm-dd" briefly (FE optimistic), then change to "Expenses #id" format (BE response).

@Beamanator
Copy link
Contributor

I like the idea of moving forward with this, BUT i don't necessarily love the idea of optimistic & BE being different, especially in case the BE changes takes a long time.

@neil-marcellini Can you help advise if it would make sense to move forward with this while you're working on the linked issue?

@neil-marcellini
Copy link
Contributor

Yes I agree I don't think the optimistic data should be different from the backend data. I think we should hold this on the auto report title project. Instead, would you guys be interested in helping with this? Plan and implement a system for optimistic report title formula computation.

@neil-marcellini
Copy link
Contributor

Actually instead of holding I'm going to close this as not planned, since it will be fixed as part of that project.

@neil-marcellini neil-marcellini closed this as not planned Won't fix, can't repro, duplicate, stale Apr 14, 2025
@github-project-automation github-project-automation bot moved this from Bugs and Follow Up Issues to Done in #expensify-bugs Apr 14, 2025
@nkdengineer
Copy link
Contributor

@neil-marcellini Can you help advise if it would make sense to move forward with this while you're working on the linked issue?

@neil-marcellini This is only the back-end part of this issue. We still have the front-end bug with optimistic data here that we need to fix this, please help to re-open this issue.

@neil-marcellini
Copy link
Contributor

neil-marcellini commented Apr 14, 2025

The linked issue is specifically for the frontend.

@nkdengineer
Copy link
Contributor

The linked issue is specifically for the frontend.

@neil-marcellini I mean, we're having another bug with Expense preview that isn't related to this issue.

The current issue is that the Report title of report preview will have the format "Expenses yyyy-mm-dd" briefly (FE optimistic), then change to "Expenses #id" format (BE response).

The problem we want to confirm here is will this issue fix this backend bug

@neil-marcellini
Copy link
Contributor

Yes we'll make sure the frontend and backend report title computations work the same way.

@nkdengineer
Copy link
Contributor

Yes we'll make sure the frontend and backend report title computations work the same way.

@neil-marcellini Got it now. But our bug here is that the report preview doesn't show the expense report name in offline. And the RCA is not related to the report title computations. It's related to childReportName isn't set of the REPORTPREVIEW action.

@hoangzinh
Copy link
Contributor

Agreed with @nkdengineer, the original bug of this issue is report title part is blank because we missed adding optimistic data for report preview. You can take a look at this proposal #59525 (comment) @neil-marcellini

@nkdengineer
Copy link
Contributor

@neil-marcellini Please help to check this comment above.

@neil-marcellini
Copy link
Contributor

Agreed with @nkdengineer, the original bug of this issue is report title part is blank because we missed adding optimistic data for report preview. You can take a look at this proposal #59525 (comment) @neil-marcellini

Right that would be good to fix, but I'm still not clear on whether we can fix this without creating an inconsistency between the optimistic and backend data. If so, please update your proposal to do exactly that and explain why there is no inconsistency. If not, we should keep this closed and fix it holistically.

@hoangzinh
Copy link
Contributor

I see. Actually, I'm unsure what the correct way to fix it from FE side. I mean, should we use iouReport.reportName or generate its own report name based on policy.fieldList.text_title.defaultValue. I'm happy to close this issue and fix it holistically here #59525 (comment)

@hoangzinh
Copy link
Contributor

@isabelastisser, because the proposal has been accepted and the PR was created. Can you process payment here for @nkdengineer and me? Then we can close this issue.

@isabelastisser
Copy link
Contributor

Payment summary:

$250 for C+ review to @hoangzinh, PENDING in NewDot.
$250 for proposal to @nkdengineer. Paid in Upwork here.

@hoangzinh
Copy link
Contributor

Thank you @isabelastisser. I requested in ND

@garrettmknight
Copy link
Contributor

$250 approved for @hoangzinh

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. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
Status: Done
Development

No branches or pull requests

8 participants