Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe
isComposerFullSize={!!isComposerFullSize}
lastReportAction={lastReportAction}
reportTransactions={transactions}
transactionThreadReportID={transactionThreadReportID}
/>
<PortalHost name="suggestions" />
</>
Expand Down
9 changes: 4 additions & 5 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
let currentUserAccountID = -1;
let currentUserEmail: string | undefined;

Onyx.connect({

Check warning on line 273 in src/libs/actions/Report.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
// When signed out, val is undefined
Expand All @@ -283,13 +283,13 @@
},
});

Onyx.connect({

Check warning on line 286 in src/libs/actions/Report.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.CONCIERGE_REPORT_ID,
callback: (value) => (conciergeReportID = value),
});

let preferredSkinTone: number = CONST.EMOJI_DEFAULT_SKIN_TONE;
Onyx.connect({

Check warning on line 292 in src/libs/actions/Report.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PREFERRED_EMOJI_SKIN_TONE,
callback: (value) => {
preferredSkinTone = EmojiUtils.getPreferredSkinToneIndex(value);
Expand All @@ -299,7 +299,7 @@
// map of reportID to all reportActions for that report
const allReportActions: OnyxCollection<ReportActions> = {};

Onyx.connect({

Check warning on line 302 in src/libs/actions/Report.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
callback: (actions, key) => {
if (!key || !actions) {
Expand All @@ -311,14 +311,14 @@
});

let allTransactionViolations: OnyxCollection<TransactionViolations> = {};
Onyx.connect({

Check warning on line 314 in src/libs/actions/Report.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => (allTransactionViolations = value),
});

let allReports: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 321 in src/libs/actions/Report.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -328,7 +328,7 @@

let isNetworkOffline = false;
let networkStatus: NetworkStatus;
Onyx.connect({

Check warning on line 331 in src/libs/actions/Report.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NETWORK,
callback: (value) => {
isNetworkOffline = value?.isOffline ?? false;
Expand All @@ -337,7 +337,7 @@
});

let allPersonalDetails: OnyxEntry<PersonalDetailsList> = {};
Onyx.connect({

Check warning on line 340 in src/libs/actions/Report.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
allPersonalDetails = value ?? {};
Expand All @@ -345,7 +345,7 @@
});

let account: OnyxEntry<Account> = {};
Onyx.connect({

Check warning on line 348 in src/libs/actions/Report.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.ACCOUNT,
callback: (value) => {
account = value ?? {};
Expand All @@ -353,7 +353,7 @@
});

const draftNoteMap: OnyxCollection<string> = {};
Onyx.connect({

Check warning on line 356 in src/libs/actions/Report.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.PRIVATE_NOTES_DRAFT,
callback: (value, key) => {
if (!key) {
Expand Down Expand Up @@ -5855,19 +5855,18 @@

/**
* 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) {
Comment on lines +5858 to +5863

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return;
}

addComment(reportID, selectedCategory);

Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${actionReportID}`, {
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {
[reportActionID]: {
originalMessage: {
selectedCategory,
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
isComposerFullSize={!!isComposerFullSize}
lastReportAction={lastReportAction}
reportTransactions={reportTransactions}
transactionThreadReportID={transactionThreadReportID}
/>
) : null}
</View>
Expand Down
25 changes: 13 additions & 12 deletions src/pages/home/report/PureReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ function PureReportActionItem({
];
}

const reportActionReportID = originalReportID ?? reportID;
if (isConciergeCategoryOptions(action)) {
const options = getOriginalMessage(action)?.options;
if (!options) {
Expand All @@ -713,15 +714,15 @@ function PureReportActionItem({
return [];
}

if (!reportID) {
if (!reportActionReportID) {
return [];
}

return options.map((option, i) => ({
text: `${i + 1} - ${option}`,
key: `${action.reportActionID}-conciergeCategoryOptions-${option}`,
onPress: () => {
resolveConciergeCategoryOptions(reportID, originalReportID, action.reportActionID, option);
resolveConciergeCategoryOptions(reportActionReportID, action.reportActionID, option);
},
}));
}
Expand All @@ -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);
},
},
];
Expand All @@ -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);
},
},
);
Expand All @@ -764,7 +765,7 @@ function PureReportActionItem({
text: 'actionableMentionTrackExpense.nothing',
key: `${action.reportActionID}-actionableMentionTrackExpense-nothing`,
onPress: () => {
dismissTrackExpenseActionableWhisper(reportID, action);
dismissTrackExpenseActionableWhisper(reportActionReportID, action);
},
});
return options;
Expand All @@ -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),
},
];
}
Expand All @@ -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),
},
];
}
Expand All @@ -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),
},
];
}, [
Expand Down
12 changes: 10 additions & 2 deletions src/pages/home/report/ReportFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ type ReportFooterProps = {
/** Report transactions */
reportTransactions?: OnyxEntry<OnyxTypes.Transaction[]>;

/** The ID of the transaction thread report if there is a single transaction */
transactionThreadReportID?: string;

/** The policy of the report */
policy: OnyxEntry<OnyxTypes.Policy>;

Expand Down Expand Up @@ -82,6 +85,7 @@ function ReportFooter({
onComposerBlur,
onComposerFocus,
reportTransactions,
transactionThreadReportID,
}: ReportFooterProps) {
const styles = useThemeStyles();
const {isOffline} = useNetwork();
Expand Down Expand Up @@ -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);
Expand Down
Loading