Open lanitochka17 opened 6 days ago
Triggered auto assignment to @anmurali (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.
We think that this bug might be related to #wave-control
@anmurali FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors
@anmurali Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
Report header title changes to Workspace owes X after editing custom name field.
When a user sets a custom report name, the response from the SetPolicyDefaultReportTitle
request changes the attribute type
in the text_title
report field from "formula"
to "text"
for the policy fields.
Hence, the getMoneyRequestReportName
function doesn't return the value of report.reportName
since the titleReportField
is undefined
.
This is because the getFormulaTypeReportField
function only finds a report field where the type
is "formula"
Let's remove titleReportField
from this condition to allow the value of report?.reportName
to be returned.
Therefore, the condition should resemble the one below.
if (report?.reportName && isPaidGroupPolicyExpenseReport(report)) {
Job added to Upwork: https://www.upwork.com/jobs/~021853969647585038505
Triggered auto assignment to Contributor-plus team member for initial proposal review - @c3024 (External
)
Report header title changes to Workspace owes X after editing custom name field
The title
is obtained from getReportName
. if the report name is available in the cache, it will be retrieved from there. If it is not in the cache, it will be retrieved using getMoneyRequestReportName
.
https://github.com/Expensify/App/blob/0f03601422dc02a42b5cf6bbc748b14be3cd1695/src/components/AvatarWithDisplayName.tsx#L74
https://github.com/Expensify/App/blob/0f03601422dc02a42b5cf6bbc748b14be3cd1695/src/libs/ReportUtils.ts#L4016-L4018
For the first expense created without setting up Rules
or Report fields
, fieldList
will not be contained in report
or policy
, and the report isn't set. Therefore, reportFields
will be received from getReportFieldsByPolicyID
, with reportFields
having type='formula'
. As a result, const titleReportField = getFormulaTypeReportField(reportFields ?? {})
will return the text report fields object
. Consequently, getMoneyRequestReportName
will return the report name, and we will see Expense Report #number
displayed in the header
After that, we went on to set Rules
or Report fields
, enabled Custom report names
, and input report
, which is a text type (not a formula). At that point, fieldList
exists in policy
.Therefore, reportFields
will be received from report?.fieldList
having type='text'
because we input report
when setting up Custom report names
. so const titleReportField = getFormulaTypeReportField(reportFields ?? {})
will return undefined
because reportFields.type === 'text'
. As a result, we can't retrieve the report name, and getMoneyRequestReportName
will return Localize.translateLocal('iou.payerOwesAmount', {payer: payerOrApproverName, amount: formattedAmount});,
which is why we see Workspace owes X
This issue happens after editing the custom name field because, before editing the custom name, the cache exists and we retrieve the value from the cache to display. After editing, we update the cache with the new value, so the new title will display after editing.
To resolve this issue, we must cover the case where report?.fieldList
has type = 'text'
and still return the report name. Something like this:
//.src/libs/ReportUtils.ts#L2935
+ function getTextTypeReportField(reportFields: Record<string, PolicyReportField>) {
+ return Object.values(reportFields).find((field) => field?.type === 'text');
+ }
getMoneyRequestReportName
function to return the report name
function getMoneyRequestReportName(report: OnyxEntry<Report>, policy?: OnyxEntry<Policy>, invoiceReceiverPolicy?: OnyxEntry<Policy>): string {
...
//.src/libs/ReportUtils.ts#L3020
+ const textTypeReportTitle = getTextTypeReportField(reportFields ?? {});
Optional: getMoneyRequestReportName
is used for both money request reports and invoice reports. So, if we want it to be specific to only the money request report, it would be like this:
function getMoneyRequestReportName(report: OnyxEntry<Report>, policy?: OnyxEntry<Policy>, invoiceReceiverPolicy?: OnyxEntry<Policy>): string {
...
//.src/libs/ReportUtils.ts#L3020
+ const textTypeReportTitle = getTextTypeReportField(reportFields ?? {});
- if (titleReportField && report?.reportName && isPaidGroupPolicyExpenseReport(report)) {
+ if ((invoiceReceiverPolicy ? titleReportField : titleReportField ?? textTypeReportTitle) && report?.reportName && isPaidGroupPolicyExpenseReport(report)) {
return report.reportName;
}
Expense - Report header title changes to Workspace owes X after editing custom name field
We display the report.reportName only when the title field exists here
https://github.com/Expensify/App/blob/8a83e2baa1c7ce7ee2c31103574937c0484854be/src/libs/ReportUtils.ts#L3015-L3018
but the method we use to get the title report field is by searching for a report field with type formula so whenever the title field is set to non-formula text that condition will be unsatisfied and we will show the owes ...
title
The correct way to check if there it the title field is via the fieldID, so we should change it to
const titleReportField = Object.values(reportFields ?? {}).find((reportField) => reportField?.fieldID === CONST.REPORT_FIELD_TITLE_FIELD_ID);
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.0.56-2 Reproducible in staging?: Y Reproducible in production?: Y If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Y 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): applausetester+kh2310001@applause.expensifail.com Issue reported by: Applause - Internal Team
Action Performed:
Expected Result:
The report header title should still display Expense Report #number (Old Dot behavior)
Actual Result:
The report header title changes to Workspace owes X after editing custom name field
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
https://github.com/user-attachments/assets/7a29a435-e880-41f5-930b-59aa5f04e0df
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @c3024