Skip to content

Commit 066fe9b

Browse files
committed
add actionReport and actionReportID calc in ActionContentRouter
1 parent 0927cac commit 066fe9b

8 files changed

Lines changed: 44 additions & 53 deletions

src/pages/inbox/report/actionContents/ActionContentRouter.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ function ActionContentRouter({
154154
const {translate, formatTravelDate} = useLocalize();
155155
const styles = useThemeStyles();
156156

157+
const actionReport = originalReport ?? report;
158+
const actionReportID = originalReportID ?? reportID;
159+
157160
if (isIOURequestReportAction(action)) {
158161
const moneyRequestOriginalMessage = isMoneyRequestAction(action) ? getOriginalMessage(action) : undefined;
159162
// If originalMessage.iouReportID is set, this is a 1:1 IOU expense in a DM chat whose reportID is report.chatReportID
@@ -361,8 +364,7 @@ function ActionContentRouter({
361364
return (
362365
<JoinRequestContent
363366
action={action}
364-
reportID={reportID}
365-
originalReportID={originalReportID}
367+
actionReportID={actionReportID}
366368
policyID={report?.policyID}
367369
/>
368370
);
@@ -382,8 +384,7 @@ function ActionContentRouter({
382384
<ReportMentionWhisperContent
383385
action={action}
384386
reportID={reportID}
385-
report={report}
386-
originalReport={originalReport}
387+
actionReport={actionReport}
387388
isReportArchived={isReportArchived}
388389
/>
389390
);
@@ -393,8 +394,7 @@ function ActionContentRouter({
393394
<ConfirmWhisperContent
394395
action={action}
395396
reportID={reportID}
396-
report={report}
397-
originalReport={originalReport}
397+
actionReport={actionReport}
398398
originalReportID={originalReportID}
399399
/>
400400
);
@@ -475,7 +475,8 @@ function ActionContentRouter({
475475
<ChatMessageContent
476476
action={action}
477477
report={report}
478-
originalReport={originalReport}
478+
actionReport={actionReport}
479+
actionReportID={actionReportID}
479480
reportID={reportID}
480481
originalReportID={originalReportID}
481482
displayAsGroup={displayAsGroup}

src/pages/inbox/report/actionContents/ChatActionableButtons.tsx

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@ import type * as OnyxTypes from '@src/types/onyx';
3636

3737
type ChatActionableButtonsProps = {
3838
action: OnyxTypes.ReportAction;
39-
report: OnyxEntry<OnyxTypes.Report>;
40-
originalReport: OnyxEntry<OnyxTypes.Report>;
39+
actionReport: OnyxEntry<OnyxTypes.Report>;
40+
actionReportID: string | undefined;
4141
reportID: string | undefined;
42-
originalReportID: string;
4342
};
4443

45-
function ChatActionableButtons({action, report, originalReport, reportID, originalReportID}: ChatActionableButtonsProps) {
44+
function ChatActionableButtons({action, actionReport, actionReportID, reportID}: ChatActionableButtonsProps) {
4645
const styles = useThemeStyles();
4746
const personalDetail = useCurrentUserPersonalDetails();
4847
const {isRestrictedToPreferredPolicy, preferredPolicyID} = usePreferredPolicy();
@@ -72,7 +71,6 @@ function ChatActionableButtons({action, report, originalReport, reportID, origin
7271
];
7372
}
7473

75-
const reportActionReport = originalReport ?? report;
7674
if (isConciergeCategoryOptions(action)) {
7775
const options = getOriginalMessage(action)?.options;
7876
if (!options) {
@@ -83,7 +81,7 @@ function ChatActionableButtons({action, report, originalReport, reportID, origin
8381
return [];
8482
}
8583

86-
if (!reportActionReport) {
84+
if (!actionReport) {
8785
return [];
8886
}
8987

@@ -92,7 +90,7 @@ function ChatActionableButtons({action, report, originalReport, reportID, origin
9290
key: `${action.reportActionID}-conciergeCategoryOptions-${option}`,
9391
onPress: () => {
9492
resolveConciergeCategoryOptions(
95-
reportActionReport,
93+
actionReport,
9694
reportID,
9795
action.reportActionID,
9896
option,
@@ -114,7 +112,7 @@ function ChatActionableButtons({action, report, originalReport, reportID, origin
114112
return [];
115113
}
116114

117-
if (!reportActionReport) {
115+
if (!actionReport) {
118116
return [];
119117
}
120118

@@ -123,7 +121,7 @@ function ChatActionableButtons({action, report, originalReport, reportID, origin
123121
key: `${action.reportActionID}-conciergeDescriptionOptions-${option}`,
124122
onPress: () => {
125123
resolveConciergeDescriptionOptions(
126-
reportActionReport,
124+
actionReport,
127125
reportID,
128126
action.reportActionID,
129127
option,
@@ -135,7 +133,7 @@ function ChatActionableButtons({action, report, originalReport, reportID, origin
135133
}));
136134
}
137135
const messageHtml = getReportActionMessage(action)?.html;
138-
if (messageHtml && reportActionReport) {
136+
if (messageHtml && actionReport) {
139137
const followups = parseFollowupsFromHtml(messageHtml);
140138
if (followups && followups.length > 0) {
141139
return followups.map((followup) => ({
@@ -144,7 +142,7 @@ function ChatActionableButtons({action, report, originalReport, reportID, origin
144142
key: `${action.reportActionID}-followup-${followup.text}`,
145143
onPress: () => {
146144
resolveSuggestedFollowup(
147-
reportActionReport,
145+
actionReport,
148146
reportID,
149147
action,
150148
followup,
@@ -159,9 +157,8 @@ function ChatActionableButtons({action, report, originalReport, reportID, origin
159157
}
160158

161159
if (isActionableTrackExpense(action)) {
162-
const reportActionReportID = originalReportID ?? reportID;
163160
const baseDraftTransactionParams = {
164-
reportID: reportActionReportID,
161+
reportID: actionReportID,
165162
reportActionID: action.reportActionID,
166163
introSelected,
167164
draftTransactionIDs,
@@ -199,7 +196,7 @@ function ChatActionableButtons({action, report, originalReport, reportID, origin
199196
text: 'actionableMentionTrackExpense.nothing',
200197
key: `${action.reportActionID}-actionableMentionTrackExpense-nothing`,
201198
onPress: () => {
202-
dismissTrackExpenseActionableWhisper(reportActionReportID, action);
199+
dismissTrackExpenseActionableWhisper(actionReportID, action);
203200
},
204201
});
205202
return options;

src/pages/inbox/report/actionContents/ChatMessageContent.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import ChatActionableButtons from './ChatActionableButtons';
2828
type ChatMessageContentProps = {
2929
action: OnyxTypes.ReportAction;
3030
report: OnyxEntry<OnyxTypes.Report>;
31-
originalReport: OnyxEntry<OnyxTypes.Report>;
31+
actionReport: OnyxEntry<OnyxTypes.Report>;
32+
actionReportID: string | undefined;
3233
reportID: string | undefined;
3334
originalReportID: string;
3435
displayAsGroup: boolean;
@@ -43,7 +44,8 @@ type ChatMessageContentProps = {
4344
function ChatMessageContent({
4445
action,
4546
report,
46-
originalReport,
47+
actionReport,
48+
actionReportID,
4749
reportID,
4850
originalReportID,
4951
displayAsGroup,
@@ -102,10 +104,9 @@ function ChatMessageContent({
102104
{mayHaveActionableButtons && (
103105
<ChatActionableButtons
104106
action={action}
105-
report={report}
106-
originalReport={originalReport}
107+
actionReport={actionReport}
108+
actionReportID={actionReportID}
107109
reportID={reportID}
108-
originalReportID={originalReportID}
109110
/>
110111
)}
111112
</View>

src/pages/inbox/report/actionContents/ConfirmWhisperContent.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,19 @@ type ConfirmWhisperContentProps = {
1414
action: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_MENTION_INVITE_TO_SUBMIT_EXPENSE_CONFIRM_WHISPER>;
1515
reportID: string | undefined;
1616
originalReportID: string | undefined;
17-
report: OnyxEntry<Report>;
18-
originalReport: OnyxEntry<Report>;
17+
actionReport: OnyxEntry<Report>;
1918
};
2019

21-
function ConfirmWhisperContent({action, reportID, originalReportID, report, originalReport}: ConfirmWhisperContentProps) {
22-
const reportActionReport = originalReport ?? report;
20+
function ConfirmWhisperContent({action, reportID, originalReportID, actionReport}: ConfirmWhisperContentProps) {
2321
const isOriginalReportArchived = useReportIsArchived(originalReportID);
24-
const mentionReportContextValue = {currentReportID: report?.reportID, exactlyMatch: true};
22+
const mentionReportContextValue = {currentReportID: reportID, exactlyMatch: true};
2523

2624
const buttons: ActionableItem[] = [
2725
{
2826
text: 'common.buttonConfirm',
2927
key: `${action.reportActionID}-actionableReportMentionConfirmWhisper-${CONST.REPORT.ACTIONABLE_MENTION_INVITE_TO_SUBMIT_EXPENSE_CONFIRM_WHISPER.DONE}`,
3028
onPress: () =>
31-
resolveActionableMentionConfirmWhisper(reportActionReport, action, CONST.REPORT.ACTIONABLE_MENTION_INVITE_TO_SUBMIT_EXPENSE_CONFIRM_WHISPER.DONE, isOriginalReportArchived),
29+
resolveActionableMentionConfirmWhisper(actionReport, action, CONST.REPORT.ACTIONABLE_MENTION_INVITE_TO_SUBMIT_EXPENSE_CONFIRM_WHISPER.DONE, isOriginalReportArchived),
3230
isPrimary: true,
3331
},
3432
];

src/pages/inbox/report/actionContents/JoinRequestContent.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,28 @@ import type {JoinWorkspaceResolution} from '@src/types/onyx/OriginalMessage';
1414

1515
type JoinRequestContentProps = {
1616
action: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_JOIN_REQUEST>;
17-
reportID: string | undefined;
18-
originalReportID: string;
17+
actionReportID: string | undefined;
1918
policyID: string | undefined;
2019
};
2120

22-
function JoinRequestContent({action, reportID, originalReportID, policyID}: JoinRequestContentProps) {
21+
function JoinRequestContent({action, actionReportID, policyID}: JoinRequestContentProps) {
2322
const {translate} = useLocalize();
2423
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
2524

26-
const reportActionReportID = originalReportID ?? reportID;
2725
const buttons: ActionableItem[] =
2826
getOriginalMessage(action)?.choice !== ('' as JoinWorkspaceResolution)
2927
? []
3028
: [
3129
{
3230
text: 'actionableMentionJoinWorkspaceOptions.accept',
3331
key: `${action.reportActionID}-actionableMentionJoinWorkspace-${CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.ACCEPT}`,
34-
onPress: () => acceptJoinRequest(reportActionReportID, action),
32+
onPress: () => acceptJoinRequest(actionReportID, action),
3533
isPrimary: true,
3634
},
3735
{
3836
text: 'actionableMentionJoinWorkspaceOptions.decline',
3937
key: `${action.reportActionID}-actionableMentionJoinWorkspace-${CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.DECLINE}`,
40-
onPress: () => declineJoinRequest(reportActionReportID, action),
38+
onPress: () => declineJoinRequest(actionReportID, action),
4139
},
4240
];
4341

src/pages/inbox/report/actionContents/MentionWhisperContent.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function MentionWhisperContent({action, report, originalReport, originalReportID
2828
const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
2929
const [personalPolicyID] = useOnyx(ONYXKEYS.PERSONAL_POLICY_ID);
3030

31-
const reportActionReport = originalReport ?? report;
31+
const actionReport = originalReport ?? report;
3232
const reportPolicyID = report?.policyID;
3333
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${reportPolicyID}`);
3434

@@ -42,7 +42,7 @@ function MentionWhisperContent({action, report, originalReport, originalReportID
4242
key: `${action.reportActionID}-actionableMentionWhisper-${CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.INVITE_TO_SUBMIT_EXPENSE}`,
4343
onPress: () =>
4444
resolveActionableMentionWhisper(
45-
reportActionReport,
45+
actionReport,
4646
action,
4747
CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.INVITE_TO_SUBMIT_EXPENSE,
4848
isOriginalReportArchived,
@@ -56,7 +56,7 @@ function MentionWhisperContent({action, report, originalReport, originalReportID
5656
key: `${action.reportActionID}-actionableMentionWhisper-${CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.INVITE}`,
5757
onPress: () =>
5858
resolveActionableMentionWhisper(
59-
reportActionReport,
59+
actionReport,
6060
action,
6161
CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.INVITE,
6262
isOriginalReportArchived,
@@ -68,7 +68,7 @@ function MentionWhisperContent({action, report, originalReport, originalReportID
6868
key: `${action.reportActionID}-actionableMentionWhisper-${CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.NOTHING}`,
6969
onPress: () =>
7070
resolveActionableMentionWhisper(
71-
reportActionReport,
71+
actionReport,
7272
action,
7373
CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.NOTHING,
7474
isOriginalReportArchived,

src/pages/inbox/report/actionContents/ReportMentionWhisperContent.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,27 @@ import type {Report, ReportAction} from '@src/types/onyx';
1313
type ReportMentionWhisperContentProps = {
1414
action: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_REPORT_MENTION_WHISPER>;
1515
reportID: string | undefined;
16-
report: OnyxEntry<Report>;
17-
originalReport: OnyxEntry<Report>;
16+
actionReport: OnyxEntry<Report>;
1817
isReportArchived: boolean;
1918
};
2019

21-
function ReportMentionWhisperContent({action, reportID, report, originalReport, isReportArchived}: ReportMentionWhisperContentProps) {
22-
const reportActionReport = originalReport ?? report;
20+
function ReportMentionWhisperContent({action, reportID, actionReport, isReportArchived}: ReportMentionWhisperContentProps) {
2321
const resolution = getOriginalMessage(action)?.resolution;
24-
const mentionReportContextValue = {currentReportID: report?.reportID, exactlyMatch: true};
22+
const mentionReportContextValue = {currentReportID: reportID, exactlyMatch: true};
2523

2624
const buttons: ActionableItem[] = resolution
2725
? []
2826
: [
2927
{
3028
text: 'common.yes',
3129
key: `${action.reportActionID}-actionableReportMentionWhisper-${CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.CREATE}`,
32-
onPress: () => resolveActionableReportMentionWhisper(reportActionReport, action, CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.CREATE, isReportArchived),
30+
onPress: () => resolveActionableReportMentionWhisper(actionReport, action, CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.CREATE, isReportArchived),
3331
isPrimary: true,
3432
},
3533
{
3634
text: 'common.no',
3735
key: `${action.reportActionID}-actionableReportMentionWhisper-${CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.NOTHING}`,
38-
onPress: () => resolveActionableReportMentionWhisper(reportActionReport, action, CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.NOTHING, isReportArchived),
36+
onPress: () => resolveActionableReportMentionWhisper(actionReport, action, CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.NOTHING, isReportArchived),
3937
},
4038
];
4139

tests/unit/WhisperContentMentionContextTest.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ describe('Whisper content components provide MentionReportContext so room mentio
9595
<ReportMentionWhisperContent
9696
action={action as ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_REPORT_MENTION_WHISPER>}
9797
reportID={REPORT_ID}
98-
report={report}
99-
originalReport={undefined}
98+
actionReport={report}
10099
isReportArchived={false}
101100
/>
102101
</OnyxListItemProvider>,
@@ -116,8 +115,7 @@ describe('Whisper content components provide MentionReportContext so room mentio
116115
action={action as ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_MENTION_INVITE_TO_SUBMIT_EXPENSE_CONFIRM_WHISPER>}
117116
reportID={REPORT_ID}
118117
originalReportID={undefined}
119-
report={report}
120-
originalReport={undefined}
118+
actionReport={report}
121119
/>
122120
</OnyxListItemProvider>,
123121
);

0 commit comments

Comments
 (0)