Skip to content

Commit 55ffc9f

Browse files
committed
self subscribe to useCurrentUserPersonalDetails
1 parent 28cd321 commit 55ffc9f

4 files changed

Lines changed: 37 additions & 30 deletions

File tree

src/pages/inbox/report/PureReportActionItem.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ import {
7777
getIOUReportIDFromReportActionPreview,
7878
getOriginalMessage,
7979
getPlaidBalanceFailureMessage,
80-
getReimbursedMessage,
8180
getRenamedAction,
8281
getReportActionHtml,
8382
getReportActionMessage,
@@ -149,6 +148,7 @@ import MentionWhisperContent from './actionContents/MentionWhisperContent';
149148
import ModifiedExpenseContent from './actionContents/ModifiedExpenseContent';
150149
import PaymentContent from './actionContents/PaymentContent';
151150
import PolicyChangeLogContent, {isHandledPolicyChangeLogAction} from './actionContents/PolicyChangeLogContent';
151+
import ReimbursedContent from './actionContents/ReimbursedContent';
152152
import ReimbursementDeQueuedContent from './actionContents/ReimbursementDeQueuedContent';
153153
import ReportMentionWhisperContent from './actionContents/ReportMentionWhisperContent';
154154
import SimpleMessageContent, {isSimpleMessageAction} from './actionContents/SimpleMessageContent';
@@ -942,7 +942,12 @@ function PureReportActionItem({
942942
/>
943943
);
944944
} else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REIMBURSED)) {
945-
children = <ReportActionItemBasicMessage message={getReimbursedMessage(translate, action, report, currentUserAccountID)} />;
945+
children = (
946+
<ReimbursedContent
947+
action={action}
948+
report={report}
949+
/>
950+
);
946951
} else if (isSimpleMessageAction(action)) {
947952
children = <SimpleMessageContent action={action} />;
948953
} else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.FORWARDED)) {
@@ -1021,7 +1026,6 @@ function PureReportActionItem({
10211026
report={report}
10221027
originalReport={originalReport}
10231028
policy={policy}
1024-
currentUserAccountID={currentUserAccountID}
10251029
personalPolicyID={personalPolicyID}
10261030
originalReportID={originalReportID}
10271031
resolveActionableMentionWhisper={resolveActionableMentionWhisper}
@@ -1186,7 +1190,6 @@ function PureReportActionItem({
11861190
accountIDs={oldestFourAccountIDs}
11871191
onSecondaryInteraction={showPopover}
11881192
isActive={isReportActionActive && !isContextMenuActive}
1189-
currentUserAccountID={currentUserAccountID}
11901193
/>
11911194
</View>
11921195
)}

src/pages/inbox/report/ReportActionItemThread.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {OnyxEntry} from 'react-native-onyx';
55
import PressableWithSecondaryInteraction from '@components/PressableWithSecondaryInteraction';
66
import ReportActionAvatars from '@components/ReportActionAvatars';
77
import Text from '@components/Text';
8+
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
89
import useLocalize from '@hooks/useLocalize';
910
import useOnyx from '@hooks/useOnyx';
1011
import useThemeStyles from '@hooks/useThemeStyles';
@@ -37,24 +38,11 @@ type ReportActionItemThreadProps = {
3738

3839
/** The function that should be called when the thread is LongPressed or right-clicked */
3940
onSecondaryInteraction: (event: GestureResponderEvent | MouseEvent) => void;
40-
41-
/** The accountID of the current user, used for creating optimistic report if needed */
42-
currentUserAccountID: number;
4341
};
4442

45-
function ReportActionItemThread({
46-
numberOfReplies,
47-
accountIDs,
48-
mostRecentReply,
49-
report,
50-
reportAction,
51-
isHovered,
52-
onSecondaryInteraction,
53-
isActive,
54-
currentUserAccountID,
55-
}: ReportActionItemThreadProps) {
43+
function ReportActionItemThread({numberOfReplies, accountIDs, mostRecentReply, report, reportAction, isHovered, onSecondaryInteraction, isActive}: ReportActionItemThreadProps) {
5644
const styles = useThemeStyles();
57-
45+
const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
5846
const {translate, datetimeToCalendarTime} = useLocalize();
5947
const [childReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportAction.childReportID}`);
6048
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {ValueOf} from 'type-fest';
44
import RenderHTML from '@components/RenderHTML';
55
import type {ActionableItem} from '@components/ReportActionItem/ActionableItemButtons';
66
import ActionableItemButtons from '@components/ReportActionItem/ActionableItemButtons';
7+
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
78
import useLocalize from '@hooks/useLocalize';
89
import useReportIsArchived from '@hooks/useReportIsArchived';
910
import {isPolicyAdmin, isPolicyMember, isPolicyOwner} from '@libs/PolicyUtils';
@@ -17,7 +18,6 @@ type MentionWhisperContentProps = {
1718
report: OnyxEntry<Report>;
1819
originalReport: OnyxEntry<Report>;
1920
policy: OnyxEntry<Policy>;
20-
currentUserAccountID: number;
2121
personalPolicyID: string | undefined;
2222
originalReportID: string | undefined;
2323
resolveActionableMentionWhisper: (
@@ -28,18 +28,10 @@ type MentionWhisperContentProps = {
2828
) => void;
2929
};
3030

31-
function MentionWhisperContent({
32-
action,
33-
report,
34-
originalReport,
35-
policy,
36-
currentUserAccountID,
37-
personalPolicyID,
38-
originalReportID,
39-
resolveActionableMentionWhisper,
40-
}: MentionWhisperContentProps) {
31+
function MentionWhisperContent({action, report, originalReport, policy, personalPolicyID, originalReportID, resolveActionableMentionWhisper}: MentionWhisperContentProps) {
4132
const {translate} = useLocalize();
4233
const isOriginalReportArchived = useReportIsArchived(originalReportID);
34+
const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
4335

4436
const reportActionReport = originalReport ?? report;
4537
const reportPolicyID = report?.policyID;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import type {OnyxEntry} from 'react-native-onyx';
3+
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
4+
import useLocalize from '@hooks/useLocalize';
5+
import {getReimbursedMessage} from '@libs/ReportActionsUtils';
6+
import ReportActionItemBasicMessage from '@pages/inbox/report/ReportActionItemBasicMessage';
7+
import type {Report, ReportAction} from '@src/types/onyx';
8+
9+
type ReimbursedContentProps = {
10+
action: ReportAction;
11+
report: OnyxEntry<Report>;
12+
};
13+
14+
function ReimbursedContent({action, report}: ReimbursedContentProps) {
15+
const {translate} = useLocalize();
16+
const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
17+
const message = getReimbursedMessage(translate, action, report, currentUserAccountID);
18+
19+
return <ReportActionItemBasicMessage message={message} />;
20+
}
21+
22+
ReimbursedContent.displayName = 'ReimbursedContent';
23+
24+
export default ReimbursedContent;

0 commit comments

Comments
 (0)