-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[CP Staging][Better Expense Report View] Fix Send Money flow issue caused by excluding pay from one transaction thread logic #63648
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
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 |
|---|---|---|
|
|
@@ -1184,6 +1184,33 @@ function isTagModificationAction(actionName: string): boolean { | |
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Used for Send Money flow, which is a special case where we have no IOU create action and only one IOU pay action. | ||
| * In other reports, pay actions do not count as a transactions, but this is an exception to this rule. | ||
| */ | ||
| function getSendMoneyFlowOneTransactionThreadID(actions: OnyxEntry<ReportActions> | ReportAction[], chatReportID?: string) { | ||
| if (!chatReportID) { | ||
| return undefined; | ||
| } | ||
|
|
||
| const iouActions = Object.values(actions ?? {}).filter(isMoneyRequestAction); | ||
|
|
||
| // sendMoneyFlow has only one IOU action... | ||
| if (iouActions.length !== 1) { | ||
| return undefined; | ||
| } | ||
|
|
||
| // ...which is 'pay'... | ||
| const isFirstActionPay = getOriginalMessage(iouActions.at(0))?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY; | ||
|
|
||
| const {type, chatType, parentReportID, parentReportActionID} = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`] ?? {}; | ||
|
|
||
| // ...and can only be triggered on DM chats | ||
| const isDM = type === CONST.REPORT.TYPE.CHAT && !chatType && !(parentReportID && parentReportActionID); | ||
|
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. is there no helper method for this?
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. There is a simple helper |
||
|
|
||
| return isFirstActionPay && isDM ? iouActions.at(0)?.childReportID : undefined; | ||
| } | ||
|
|
||
| /** Whether action has no linked report by design */ | ||
| const isIOUActionTypeExcludedFromFiltering = (type: OriginalMessageIOU['type'] | undefined) => | ||
| [CONST.IOU.REPORT_ACTION_TYPE.SPLIT, CONST.IOU.REPORT_ACTION_TYPE.TRACK, CONST.IOU.REPORT_ACTION_TYPE.PAY].some((actionType) => actionType === type); | ||
|
|
@@ -1236,6 +1263,12 @@ function getOneTransactionThreadReportID( | |
| return; | ||
| } | ||
|
|
||
| const sendMoneyFlowID = getSendMoneyFlowOneTransactionThreadID(reportActions, report?.chatReportID); | ||
|
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. even here se should pass the full report |
||
|
|
||
| if (sendMoneyFlowID) { | ||
| return sendMoneyFlowID; | ||
| } | ||
|
|
||
| const iouRequestActions = []; | ||
| for (const action of reportActionsArray) { | ||
| // If the original message is a 'pay' IOU, it shouldn't be added to the transaction count. | ||
|
|
@@ -2601,6 +2634,7 @@ export { | |
| getWorkspaceDescriptionUpdatedMessage, | ||
| getWorkspaceReportFieldAddMessage, | ||
| getWorkspaceCustomUnitRateAddedMessage, | ||
| getSendMoneyFlowOneTransactionThreadID, | ||
| getWorkspaceTagUpdateMessage, | ||
| getWorkspaceReportFieldUpdateMessage, | ||
| getWorkspaceReportFieldDeleteMessage, | ||
|
|
||
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.
Please pass these props directly or pass the report object itself, this is not a pure function