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
2 changes: 1 addition & 1 deletion config/eslint/eslint.seatbelt.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"../../src/Expensify.tsx" "react-hooks/set-state-in-effect" 1
"../../src/GlobalModals.tsx" "no-restricted-syntax" 2
"../../src/ONYXKEYS.ts" "no-restricted-syntax" 2
"../../src/ROUTES.ts" "@typescript-eslint/no-deprecated/getUrlWithBackToParam" 105
"../../src/ROUTES.ts" "@typescript-eslint/no-deprecated/getUrlWithBackToParam" 106
"../../src/ROUTES.ts" "@typescript-eslint/no-unsafe-type-assertion" 3
"../../src/TIMEZONES.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/AccountingConnectionConfirmationModal.tsx" "@typescript-eslint/no-deprecated/ConfirmModal" 1
Expand Down
13 changes: 12 additions & 1 deletion src/libs/actions/Policy/Member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -836,8 +836,19 @@ function buildAddMembersToWorkspaceOnyxData(
const announceRoomChat = optimisticAnnounceChat.announceChatData;

const doesPersonalDetailExistByAccountID: Record<number, boolean> = {};
const newPersonalDetailAccountIDs = new Set<number>();
for (const update of newPersonalDetailsOnyxData.optimisticData ?? []) {
if (update.key !== ONYXKEYS.PERSONAL_DETAILS_LIST) {
continue;
}

for (const accountID of Object.keys(update.value ?? {})) {
newPersonalDetailAccountIDs.add(Number(accountID));
}
}

for (const accountID of accountIDs) {
doesPersonalDetailExistByAccountID[accountID] = !!personalDetailsList?.[accountID];
doesPersonalDetailExistByAccountID[accountID] = !newPersonalDetailAccountIDs.has(accountID);
}

// create onyx data for policy expense chats for each new member
Expand Down
1 change: 1 addition & 0 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ import type {
InvitedEmailsToAccountIDs,
LastPaymentMethod,
LastPaymentMethodType,
PersonalDetailsList,
Policy,
PolicyCategories,
PolicyCategory,
Expand Down
9 changes: 4 additions & 5 deletions tests/actions/PolicyMemberTest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import DateUtils from '@libs/DateUtils';
import {getPersonalDetailsOnyxDataForOptimisticUsers} from '@libs/PersonalDetailsUtils';

import CONST from '@src/CONST';
import OnyxUpdateManager from '@src/libs/actions/OnyxUpdateManager';
Expand Down Expand Up @@ -404,7 +405,7 @@ describe('actions/PolicyMember', () => {
await mockFetch?.resume?.();
});

it('uses the explicit personal details list to decide new-member success-data participants instead of the deprecated copy', () => {
it('uses new personal details onyx data to decide new-member success-data participants instead of the deprecated copy', () => {
const policyID = '1';
const policy = {...createRandomPolicy(Number(policyID))};

Expand All @@ -413,16 +414,14 @@ describe('actions/PolicyMember', () => {
const absentMemberEmail = 'absent@example.com';
const absentMemberAccountID = 8765;

// The personal details list knows the "present" member but not the "absent" one.
const personalDetailsList = {[presentMemberAccountID]: {accountID: presentMemberAccountID, login: presentMemberEmail}};
const newPersonalDetailsOnyxData = getPersonalDetailsOnyxDataForOptimisticUsers([absentMemberEmail], [absentMemberAccountID], TestHelper.formatPhoneNumber);

const {membersChats} = Member.buildAddMembersToWorkspaceOnyxData(
{[presentMemberEmail]: presentMemberAccountID, [absentMemberEmail]: absentMemberAccountID},
newPersonalDetailsOnyxData,
policy,
[],
CONST.POLICY.ROLE.USER,
TestHelper.formatPhoneNumber,
personalDetailsList,
currentUser,
undefined,
);
Expand Down
Loading