Skip to content

Commit 95e063e

Browse files
committed
allow ModifiedExpenseContent to subscribe to policy
1 parent 91de36a commit 95e063e

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/pages/inbox/report/PureReportActionItem.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,6 @@ function PureReportActionItem({
11581158
report={report}
11591159
childReport={childReport}
11601160
originalReport={originalReport}
1161-
policy={policy}
11621161
currentUserEmail={currentUserEmail}
11631162
/>
11641163
);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ import {getForReportAction, getMovedReportID} from '@libs/ModifiedExpenseMessage
77
import ReportActionItemMessageWithExplain from '@pages/inbox/report/ReportActionItemMessageWithExplain';
88
import CONST from '@src/CONST';
99
import ONYXKEYS from '@src/ONYXKEYS';
10-
import type {Policy, Report, ReportAction} from '@src/types/onyx';
10+
import type {Report, ReportAction} from '@src/types/onyx';
1111

1212
type ModifiedExpenseContentProps = {
1313
action: ReportAction;
1414
report: OnyxEntry<Report>;
1515
childReport: OnyxEntry<Report>;
1616
originalReport: OnyxEntry<Report>;
17-
policy: OnyxEntry<Policy>;
1817
currentUserEmail: string | undefined;
1918
};
2019

21-
function ModifiedExpenseContent({action, report, childReport, originalReport, policy, currentUserEmail}: ModifiedExpenseContentProps) {
20+
function ModifiedExpenseContent({action, report, childReport, originalReport, currentUserEmail}: ModifiedExpenseContentProps) {
2221
const {translate} = useLocalize();
2322
const {policyForMovingExpensesID} = usePolicyForMovingExpenses();
23+
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`);
2424

2525
// When expense is moved from self-DM to workspace, policyID is temporarily OWNER_EMAIL_FAKE.
2626
// Fall back to policyForMovingExpensesID (actual destination workspace) for correct tag list.

tests/ui/PureReportActionItemTest.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,14 @@ describe('PureReportActionItem', () => {
779779
it('MODIFIED_EXPENSE with policyRulesModifiedFields renders billable message and workspace rules link', async () => {
780780
const policyID = 'policy123';
781781

782+
// Set up policy in Onyx so ModifiedExpenseContent self-subscribes to it
783+
await act(async () => {
784+
await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {
785+
id: policyID,
786+
name: 'Test Policy',
787+
});
788+
});
789+
782790
const action = createReportAction(CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, {
783791
policyID,
784792
policyRulesModifiedFields: {billable: true},
@@ -812,7 +820,6 @@ describe('PureReportActionItem', () => {
812820
betas={undefined}
813821
draftTransactionIDs={[]}
814822
userBillingGracePeriodEnds={undefined}
815-
policy={{id: policyID} as Policy}
816823
/>
817824
</PortalProvider>
818825
</ScreenWrapper>

0 commit comments

Comments
 (0)