Skip to content
7 changes: 6 additions & 1 deletion src/libs/actions/OnyxDerived/configs/reportAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ export default createOnyxDerivedValueConfig({
ONYXKEYS.PERSONAL_DETAILS_LIST,
ONYXKEYS.SESSION,
ONYXKEYS.COLLECTION.POLICY,
ONYXKEYS.COLLECTION.POLICY_TAGS,
ONYXKEYS.COLLECTION.REPORT_METADATA,
],
compute: ([reports, preferredLocale, transactionViolations, reportActions, reportNameValuePairs, transactions, personalDetails, session, policies], {currentValue, sourceValues}) => {
compute: (
[reports, preferredLocale, transactionViolations, reportActions, reportNameValuePairs, transactions, personalDetails, session, policies, policyTags],
{currentValue, sourceValues},
) => {
// Check if display names changed when personal details are updated
let displayNamesChanged = false;
if (hasKeyTriggeredCompute(ONYXKEYS.PERSONAL_DETAILS_LIST, sourceValues)) {
Expand Down Expand Up @@ -220,6 +224,7 @@ export default createOnyxDerivedValueConfig({
reportActions,
currentUserAccountID: session?.accountID ?? CONST.DEFAULT_NUMBER_ID,
currentUserLogin: session?.email ?? '',
allPolicyTags: policyTags,
})
: '',
isEmpty: generateIsEmptyReport(report, isReportArchived),
Expand Down
21 changes: 12 additions & 9 deletions tests/unit/OnyxDerivedTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,20 @@ describe('OnyxDerived', () => {
const transaction = createRandomTransaction(1);

// When the report attributes are recomputed with both report and transaction updates
reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], {});
const reportAttributesComputedValue = reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], {
sourceValues: {
[ONYXKEYS.COLLECTION.REPORT]: {
[`${ONYXKEYS.COLLECTION.REPORT}${reportID1}`]: reports[`${ONYXKEYS.COLLECTION.REPORT}${reportID1}`],
},
[ONYXKEYS.COLLECTION.TRANSACTION]: {
[`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`]: transaction,
reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], {});
const reportAttributesComputedValue = reportAttributes.compute(
[reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined],
{
sourceValues: {
[ONYXKEYS.COLLECTION.REPORT]: {
[`${ONYXKEYS.COLLECTION.REPORT}${reportID1}`]: reports[`${ONYXKEYS.COLLECTION.REPORT}${reportID1}`],
},
[ONYXKEYS.COLLECTION.TRANSACTION]: {
[`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`]: transaction,
},
},
},
}).reports;
).reports;

// Then the computed report attributes should contain both reports
expect(Object.keys(reportAttributesComputedValue)).toEqual([reportID1, reportID2]);
Expand Down
Loading