-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Fix: Report-Expense report thread and reply title is shown as In expense report #77633
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
Changes from all commits
1276903
942b43f
89d874a
b44c2a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6029,6 +6029,40 @@ function getReportName( | |
| function getSearchReportName(props: GetReportNameParams): string { | ||
| const {report, policy} = props; | ||
| if (isChatThread(report) && policy?.name) { | ||
| // Traverse up the parent chain to find the first expense report | ||
| // If found, return the expense report name instead of workspace name | ||
| let currentParent = getParentReport(report); | ||
| const visitedReportIDs = new Set<string>(); | ||
|
|
||
| while (currentParent) { | ||
| if (!currentParent.reportID) { | ||
| break; | ||
| } | ||
| if (visitedReportIDs.has(currentParent.reportID)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we guarantee this reportID exists?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we cannot guarantee reportID exists at runtime, even though TypeScript marks it as required. So I add a guard check logic. |
||
| break; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we break, we still return policy name?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
| } | ||
| visitedReportIDs.add(currentParent.reportID); | ||
|
|
||
| if (isExpenseReport(currentParent)) { | ||
| // eslint-disable-next-line @typescript-eslint/no-deprecated | ||
| return getReportName( | ||
| currentParent, | ||
| policy, | ||
| props.parentReportActionParam, | ||
| props.personalDetails, | ||
| props.invoiceReceiverPolicy, | ||
| undefined, | ||
| props.transactions, | ||
| props.isReportArchived, | ||
| props.reports, | ||
| props.policies, | ||
| ); | ||
| } | ||
|
|
||
| // Continue traversing up the parent chain | ||
| currentParent = getParentReport(currentParent); | ||
| } | ||
|
|
||
| return policy.name; | ||
| } | ||
| // This will be fixed as follow up https://github.com/Expensify/App/pull/75357 | ||
annaweber830 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we still need this
policy?.namecheckThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check ensures we only use this special traversal logic when we have a valid policy name to return. Without it, we could return undefined instead of letting getReportName() handle the case with its fallbacks.