Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist failed personal details when adding workspace member #23947

Merged
merged 4 commits into from
Aug 2, 2023
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
1 change: 0 additions & 1 deletion src/libs/PersonalDetailsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ function getNewPersonalDetailsOnyxData(logins, accountIDs) {
* This is done to prevent duplicate entries (upon success) since the BE will return other personal details with the correct account IDs.
*/
successData[accountID] = null;
failureData[accountID] = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why we did this here... even the comment say we want to prevent dupes on success

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's a bit odd

}
});

Expand Down
30 changes: 0 additions & 30 deletions src/libs/actions/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import {escapeRegExp} from 'lodash';
import * as API from '../API';
import ONYXKEYS from '../../ONYXKEYS';
import CONST from '../../CONST';
import * as LocalePhoneNumber from '../LocalePhoneNumber';
import * as OptionsListUtils from '../OptionsListUtils';
import * as ErrorUtils from '../ErrorUtils';
import * as ReportUtils from '../ReportUtils';
import * as PersonalDetailsUtils from '../PersonalDetailsUtils';
import Log from '../Log';
import Permissions from '../Permissions';
import * as UserUtils from '../UserUtils';

const allPolicies = {};
Onyx.connect({
Expand Down Expand Up @@ -360,24 +358,6 @@ function addMembersToWorkspace(invitedEmailsToAccountIDs, welcomeNote, policyID,
// create onyx data for policy expense chats for each new member
const membersChats = createPolicyExpenseChats(policyID, invitedEmailsToAccountIDs, betas);

// Optimistic personal details for the new accounts invited
const optimisticPersonalDetails = _.chain(invitedEmailsToAccountIDs)
.map(
(accountID, memberLogin) =>
!_.has(allPersonalDetails, accountID) && [
accountID,
{
accountID,
avatar: UserUtils.getDefaultAvatarURL(accountID),
displayName: LocalePhoneNumber.formatPhoneNumber(memberLogin),
login: OptionsListUtils.addSMSDomainIfPhoneNumber(memberLogin),
},
],
)
.compact()
.object()
.value();

const optimisticData = [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand All @@ -388,11 +368,6 @@ function addMembersToWorkspace(invitedEmailsToAccountIDs, welcomeNote, policyID,
},
...newPersonalDetailsOnyxData.optimisticData,
...membersChats.onyxOptimisticData,
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
value: optimisticPersonalDetails,
},
];

const successData = [
Expand All @@ -406,11 +381,6 @@ function addMembersToWorkspace(invitedEmailsToAccountIDs, welcomeNote, policyID,
},
...newPersonalDetailsOnyxData.successData,
...membersChats.onyxSuccessData,
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
value: _.object(_.keys(optimisticPersonalDetails), Array(_.size(optimisticPersonalDetails)).fill(null)),
},
];

const failureData = [
Expand Down
Loading