Skip to content

Commit 44f190c

Browse files
Merge pull request Expensify#67707 from Expensify/aldo_add-comments-in-single-transaction-thread
Use the transaction thread reportID if there is a single transaction
2 parents 36559d4 + 4b81b49 commit 44f190c

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/components/MoneyRequestReportView/MoneyRequestReportView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe
246246
isComposerFullSize={!!isComposerFullSize}
247247
lastReportAction={lastReportAction}
248248
reportTransactions={transactions}
249+
transactionThreadReportID={transactionThreadReportID}
249250
/>
250251
<PortalHost name="suggestions" />
251252
</>

src/pages/home/ReportScreen.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
860860
isComposerFullSize={!!isComposerFullSize}
861861
lastReportAction={lastReportAction}
862862
reportTransactions={reportTransactions}
863+
transactionThreadReportID={transactionThreadReportID}
863864
/>
864865
) : null}
865866
</View>

src/pages/home/report/ReportFooter.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ type ReportFooterProps = {
5353
/** Report transactions */
5454
reportTransactions?: OnyxEntry<OnyxTypes.Transaction[]>;
5555

56+
/** The ID of the transaction thread report if there is a single transaction */
57+
transactionThreadReportID?: string;
58+
5659
/** The policy of the report */
5760
policy: OnyxEntry<OnyxTypes.Policy>;
5861

@@ -86,6 +89,7 @@ function ReportFooter({
8689
onComposerBlur,
8790
onComposerFocus,
8891
reportTransactions,
92+
transactionThreadReportID,
8993
}: ReportFooterProps) {
9094
const styles = useThemeStyles();
9195
const {isOffline} = useNetwork();
@@ -175,10 +179,14 @@ function ReportFooter({
175179
if (isTaskCreated) {
176180
return;
177181
}
178-
addComment(report.reportID, text, true);
182+
183+
// 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.
184+
// 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.
185+
const targetReportID = transactionThreadReportID ?? report.reportID;
186+
addComment(targetReportID, text, true);
179187
},
180188
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
181-
[report.reportID, handleCreateTask],
189+
[report.reportID, handleCreateTask, transactionThreadReportID],
182190
);
183191

184192
const [didHideComposerInput, setDidHideComposerInput] = useState(!shouldShowComposeInput);

0 commit comments

Comments
 (0)