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 @@ -246,7 +246,6 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe
isComposerFullSize={!!isComposerFullSize}
lastReportAction={lastReportAction}
reportTransactions={transactions}
transactionThreadReportID={transactionThreadReportID}
/>
<PortalHost name="suggestions" />
</>
Expand Down
9 changes: 5 additions & 4 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
let currentUserAccountID = -1;
let currentUserEmail: string | undefined;

Onyx.connect({

Check warning on line 276 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 @@ -286,13 +286,13 @@
},
});

Onyx.connect({

Check warning on line 289 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 295 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 @@ -302,7 +302,7 @@
// map of reportID to all reportActions for that report
const allReportActions: OnyxCollection<ReportActions> = {};

Onyx.connect({

Check warning on line 305 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 @@ -314,14 +314,14 @@
});

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

Check warning on line 317 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 324 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 @@ -331,7 +331,7 @@

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

Check warning on line 334 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 @@ -340,7 +340,7 @@
});

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

Check warning on line 343 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 @@ -348,7 +348,7 @@
});

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

Check warning on line 351 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 @@ -356,7 +356,7 @@
});

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

Check warning on line 359 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 @@ -5864,18 +5864,19 @@

/**
* Resolves Concierge category options by adding a comment and updating the report action
* @param reportID - The report ID where the comment should be added and the report action should be updated
* @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 reportActionID - The specific report action ID to update
* @param selectedCategory - The category selected by the user
*/
function resolveConciergeCategoryOptions(reportID: string | undefined, reportActionID: string | undefined, selectedCategory: string) {
if (!reportID || !reportActionID) {
function resolveConciergeCategoryOptions(reportID: string | undefined, actionReportID: string | undefined, reportActionID: string | undefined, selectedCategory: string) {
if (!reportID || !actionReportID || !reportActionID) {
return;
}

addComment(reportID, selectedCategory);

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

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

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

return options.map((option, i) => ({
text: `${i + 1} - ${option}`,
key: `${action.reportActionID}-conciergeCategoryOptions-${option}`,
onPress: () => {
resolveConciergeCategoryOptions(reportActionReportID, action.reportActionID, option);
resolveConciergeCategoryOptions(reportID, originalReportID, action.reportActionID, option);
},
}));
}
Expand All @@ -737,7 +736,7 @@ function PureReportActionItem({
text: 'actionableMentionTrackExpense.submit',
key: `${action.reportActionID}-actionableMentionTrackExpense-submit`,
onPress: () => {
createDraftTransactionAndNavigateToParticipantSelector(transactionID, reportActionReportID, CONST.IOU.ACTION.SUBMIT, action.reportActionID);
createDraftTransactionAndNavigateToParticipantSelector(transactionID, reportID, CONST.IOU.ACTION.SUBMIT, action.reportActionID);
},
},
];
Expand All @@ -748,14 +747,14 @@ function PureReportActionItem({
text: 'actionableMentionTrackExpense.categorize',
key: `${action.reportActionID}-actionableMentionTrackExpense-categorize`,
onPress: () => {
createDraftTransactionAndNavigateToParticipantSelector(transactionID, reportActionReportID, CONST.IOU.ACTION.CATEGORIZE, action.reportActionID);
createDraftTransactionAndNavigateToParticipantSelector(transactionID, reportID, CONST.IOU.ACTION.CATEGORIZE, action.reportActionID);
},
},
{
text: 'actionableMentionTrackExpense.share',
key: `${action.reportActionID}-actionableMentionTrackExpense-share`,
onPress: () => {
createDraftTransactionAndNavigateToParticipantSelector(transactionID, reportActionReportID, CONST.IOU.ACTION.SHARE, action.reportActionID);
createDraftTransactionAndNavigateToParticipantSelector(transactionID, reportID, CONST.IOU.ACTION.SHARE, action.reportActionID);
},
},
);
Expand All @@ -764,7 +763,7 @@ function PureReportActionItem({
text: 'actionableMentionTrackExpense.nothing',
key: `${action.reportActionID}-actionableMentionTrackExpense-nothing`,
onPress: () => {
dismissTrackExpenseActionableWhisper(reportActionReportID, action);
dismissTrackExpenseActionableWhisper(reportID, action);
},
});
return options;
Expand All @@ -775,13 +774,13 @@ function PureReportActionItem({
{
text: 'actionableMentionJoinWorkspaceOptions.accept',
key: `${action.reportActionID}-actionableMentionJoinWorkspace-${CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.ACCEPT}`,
onPress: () => acceptJoinRequest(reportActionReportID, action),
onPress: () => acceptJoinRequest(reportID, action),
isPrimary: true,
},
{
text: 'actionableMentionJoinWorkspaceOptions.decline',
key: `${action.reportActionID}-actionableMentionJoinWorkspace-${CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.DECLINE}`,
onPress: () => declineJoinRequest(reportActionReportID, action),
onPress: () => declineJoinRequest(reportID, action),
},
];
}
Expand All @@ -791,13 +790,13 @@ function PureReportActionItem({
{
text: 'common.yes',
key: `${action.reportActionID}-actionableReportMentionWhisper-${CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.CREATE}`,
onPress: () => resolveActionableReportMentionWhisper(reportActionReportID, action, CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.CREATE),
onPress: () => resolveActionableReportMentionWhisper(reportID, 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(reportActionReportID, action, CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.NOTHING),
onPress: () => resolveActionableReportMentionWhisper(reportID, action, CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.NOTHING),
},
];
}
Expand All @@ -806,13 +805,13 @@ function PureReportActionItem({
{
text: 'actionableMentionWhisperOptions.invite',
key: `${action.reportActionID}-actionableMentionWhisper-${CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.INVITE}`,
onPress: () => resolveActionableMentionWhisper(reportActionReportID, action, CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.INVITE),
onPress: () => resolveActionableMentionWhisper(reportID, 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(reportActionReportID, action, CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.NOTHING),
onPress: () => resolveActionableMentionWhisper(reportID, action, CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.NOTHING),
},
];
}, [
Expand Down
12 changes: 2 additions & 10 deletions src/pages/home/report/ReportFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ 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 @@ -85,7 +82,6 @@ function ReportFooter({
onComposerBlur,
onComposerFocus,
reportTransactions,
transactionThreadReportID,
}: ReportFooterProps) {
const styles = useThemeStyles();
const {isOffline} = useNetwork();
Expand Down Expand Up @@ -175,14 +171,10 @@ function ReportFooter({
if (isTaskCreated) {
return;
}

// 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);
addComment(report.reportID, text, true);
},
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
[report.reportID, handleCreateTask, transactionThreadReportID],
[report.reportID, handleCreateTask],
);

const [didHideComposerInput, setDidHideComposerInput] = useState(!shouldShowComposeInput);
Expand Down
Loading