diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx index 0f0611868f06..bf6187448dbc 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx @@ -253,6 +253,7 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe isComposerFullSize={!!isComposerFullSize} lastReportAction={lastReportAction} reportTransactions={transactions} + transactionThreadReportID={transactionThreadReportID} /> diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index f784be4a7ac2..164eeff10321 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -5855,19 +5855,18 @@ function changeReportPolicyAndInviteSubmitter(report: Report, policyID: string, /** * Resolves Concierge category options by adding a comment and updating the report action - * @param reportID - The report ID where the comment should be added - * @param actionReportID - The report ID where the report action should be updated (may be different for threads) + * @param reportID - The report ID where the comment should be added and the report action should be updated * @param reportActionID - The specific report action ID to update * @param selectedCategory - The category selected by the user */ -function resolveConciergeCategoryOptions(reportID: string | undefined, actionReportID: string | undefined, reportActionID: string | undefined, selectedCategory: string) { - if (!reportID || !actionReportID || !reportActionID) { +function resolveConciergeCategoryOptions(reportID: string | undefined, reportActionID: string | undefined, selectedCategory: string) { + if (!reportID || !reportActionID) { return; } addComment(reportID, selectedCategory); - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${actionReportID}`, { + Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, { [reportActionID]: { originalMessage: { selectedCategory, diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 445522801fa8..947b826fbce5 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -865,6 +865,7 @@ function ReportScreen({route, navigation}: ReportScreenProps) { isComposerFullSize={!!isComposerFullSize} lastReportAction={lastReportAction} reportTransactions={reportTransactions} + transactionThreadReportID={transactionThreadReportID} /> ) : null} diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index cbbe2a6eb1e4..a0d3d55977b8 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -703,6 +703,7 @@ function PureReportActionItem({ ]; } + const reportActionReportID = originalReportID ?? reportID; if (isConciergeCategoryOptions(action)) { const options = getOriginalMessage(action)?.options; if (!options) { @@ -713,7 +714,7 @@ function PureReportActionItem({ return []; } - if (!reportID) { + if (!reportActionReportID) { return []; } @@ -721,7 +722,7 @@ function PureReportActionItem({ text: `${i + 1} - ${option}`, key: `${action.reportActionID}-conciergeCategoryOptions-${option}`, onPress: () => { - resolveConciergeCategoryOptions(reportID, originalReportID, action.reportActionID, option); + resolveConciergeCategoryOptions(reportActionReportID, action.reportActionID, option); }, })); } @@ -737,7 +738,7 @@ function PureReportActionItem({ text: 'actionableMentionTrackExpense.submit', key: `${action.reportActionID}-actionableMentionTrackExpense-submit`, onPress: () => { - createDraftTransactionAndNavigateToParticipantSelector(transactionID, reportID, CONST.IOU.ACTION.SUBMIT, action.reportActionID); + createDraftTransactionAndNavigateToParticipantSelector(transactionID, reportActionReportID, CONST.IOU.ACTION.SUBMIT, action.reportActionID); }, }, ]; @@ -748,14 +749,14 @@ function PureReportActionItem({ text: 'actionableMentionTrackExpense.categorize', key: `${action.reportActionID}-actionableMentionTrackExpense-categorize`, onPress: () => { - createDraftTransactionAndNavigateToParticipantSelector(transactionID, reportID, CONST.IOU.ACTION.CATEGORIZE, action.reportActionID); + createDraftTransactionAndNavigateToParticipantSelector(transactionID, reportActionReportID, CONST.IOU.ACTION.CATEGORIZE, action.reportActionID); }, }, { text: 'actionableMentionTrackExpense.share', key: `${action.reportActionID}-actionableMentionTrackExpense-share`, onPress: () => { - createDraftTransactionAndNavigateToParticipantSelector(transactionID, reportID, CONST.IOU.ACTION.SHARE, action.reportActionID); + createDraftTransactionAndNavigateToParticipantSelector(transactionID, reportActionReportID, CONST.IOU.ACTION.SHARE, action.reportActionID); }, }, ); @@ -764,7 +765,7 @@ function PureReportActionItem({ text: 'actionableMentionTrackExpense.nothing', key: `${action.reportActionID}-actionableMentionTrackExpense-nothing`, onPress: () => { - dismissTrackExpenseActionableWhisper(reportID, action); + dismissTrackExpenseActionableWhisper(reportActionReportID, action); }, }); return options; @@ -775,13 +776,13 @@ function PureReportActionItem({ { text: 'actionableMentionJoinWorkspaceOptions.accept', key: `${action.reportActionID}-actionableMentionJoinWorkspace-${CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.ACCEPT}`, - onPress: () => acceptJoinRequest(reportID, action), + onPress: () => acceptJoinRequest(reportActionReportID, action), isPrimary: true, }, { text: 'actionableMentionJoinWorkspaceOptions.decline', key: `${action.reportActionID}-actionableMentionJoinWorkspace-${CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.DECLINE}`, - onPress: () => declineJoinRequest(reportID, action), + onPress: () => declineJoinRequest(reportActionReportID, action), }, ]; } @@ -791,13 +792,13 @@ function PureReportActionItem({ { text: 'common.yes', key: `${action.reportActionID}-actionableReportMentionWhisper-${CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.CREATE}`, - onPress: () => resolveActionableReportMentionWhisper(reportID, action, CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.CREATE), + onPress: () => resolveActionableReportMentionWhisper(reportActionReportID, action, CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.CREATE), isPrimary: true, }, { text: 'common.no', key: `${action.reportActionID}-actionableReportMentionWhisper-${CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.NOTHING}`, - onPress: () => resolveActionableReportMentionWhisper(reportID, action, CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.NOTHING), + onPress: () => resolveActionableReportMentionWhisper(reportActionReportID, action, CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.NOTHING), }, ]; } @@ -806,13 +807,13 @@ function PureReportActionItem({ { text: 'actionableMentionWhisperOptions.invite', key: `${action.reportActionID}-actionableMentionWhisper-${CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.INVITE}`, - onPress: () => resolveActionableMentionWhisper(reportID, action, CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.INVITE), + onPress: () => resolveActionableMentionWhisper(reportActionReportID, action, CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.INVITE), isPrimary: true, }, { text: 'actionableMentionWhisperOptions.nothing', key: `${action.reportActionID}-actionableMentionWhisper-${CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.NOTHING}`, - onPress: () => resolveActionableMentionWhisper(reportID, action, CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.NOTHING), + onPress: () => resolveActionableMentionWhisper(reportActionReportID, action, CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.NOTHING), }, ]; }, [ diff --git a/src/pages/home/report/ReportFooter.tsx b/src/pages/home/report/ReportFooter.tsx index bba82ceceb97..9f31948b22c1 100644 --- a/src/pages/home/report/ReportFooter.tsx +++ b/src/pages/home/report/ReportFooter.tsx @@ -53,6 +53,9 @@ type ReportFooterProps = { /** Report transactions */ reportTransactions?: OnyxEntry; + /** The ID of the transaction thread report if there is a single transaction */ + transactionThreadReportID?: string; + /** The policy of the report */ policy: OnyxEntry; @@ -82,6 +85,7 @@ function ReportFooter({ onComposerBlur, onComposerFocus, reportTransactions, + transactionThreadReportID, }: ReportFooterProps) { const styles = useThemeStyles(); const {isOffline} = useNetwork(); @@ -171,10 +175,14 @@ function ReportFooter({ if (isTaskCreated) { return; } - addComment(report.reportID, text, true); + + // If we are adding an action on an expense report that only has a single transaction thread child report, we need to add the action to the transaction thread instead. + // This is because we need it to be associated with the transaction thread and not the expense report in order for conversational corrections to work as expected. + const targetReportID = transactionThreadReportID ?? report.reportID; + addComment(targetReportID, text, true); }, // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps - [report.reportID, handleCreateTask], + [report.reportID, handleCreateTask, transactionThreadReportID], ); const [didHideComposerInput, setDidHideComposerInput] = useState(!shouldShowComposeInput);