@@ -49,7 +49,7 @@ import CONST from '@src/CONST';
4949import ONYXKEYS from '@src/ONYXKEYS' ;
5050import ROUTES from '@src/ROUTES' ;
5151import type { ExpenseRuleForm , MerchantRuleForm } from '@src/types/form' ;
52- import type { AppReview , BlockedFromConcierge , CustomStatusDraft , ExpenseRule , LoginList , Policy } from '@src/types/onyx' ;
52+ import type { AppReview , BlockedFromConcierge , CustomStatusDraft , ExpenseRule , Policy } from '@src/types/onyx' ;
5353import type Login from '@src/types/onyx/Login' ;
5454import type { Errors } from '@src/types/onyx/OnyxCommon' ;
5555import type { AnyOnyxServerUpdate , OnyxServerUpdate , OnyxUpdateEvent } from '@src/types/onyx/OnyxUpdatesFromServer' ;
@@ -511,14 +511,7 @@ function requestValidateCodeAction() {
511511/**
512512 * Validates a secondary login / contact method
513513 */
514- function validateSecondaryLogin (
515- currentUserPersonalDetails : OnyxEntry < OnyxPersonalDetails > ,
516- loginList : OnyxEntry < LoginList > ,
517- contactMethod : string ,
518- validateCode : string ,
519- formatPhoneNumber : LocaleContextProps [ 'formatPhoneNumber' ] ,
520- shouldResetActionCode ?: boolean ,
521- ) {
514+ function validateSecondaryLogin ( contactMethod : string , validateCode : string , formatPhoneNumber : LocaleContextProps [ 'formatPhoneNumber' ] , shouldResetActionCode ?: boolean ) {
522515 const optimisticData : Array < OnyxUpdate < typeof ONYXKEYS . LOGIN_LIST | typeof ONYXKEYS . ACCOUNT > > = [
523516 {
524517 onyxMethod : Onyx . METHOD . MERGE ,
@@ -544,16 +537,7 @@ function validateSecondaryLogin(
544537 } ,
545538 } ,
546539 ] ;
547- const successData : Array <
548- OnyxUpdate <
549- | typeof ONYXKEYS . LOGIN_LIST
550- | typeof ONYXKEYS . ACCOUNT
551- | typeof ONYXKEYS . SESSION
552- | typeof ONYXKEYS . PERSONAL_DETAILS_LIST
553- | typeof ONYXKEYS . COLLECTION . POLICY
554- | typeof ONYXKEYS . VALIDATE_ACTION_CODE
555- >
556- > = [
540+ const successData : Array < OnyxUpdate < typeof ONYXKEYS . LOGIN_LIST | typeof ONYXKEYS . ACCOUNT | typeof ONYXKEYS . VALIDATE_ACTION_CODE > > = [
557541 {
558542 onyxMethod : Onyx . METHOD . MERGE ,
559543 key : ONYXKEYS . LOGIN_LIST ,
@@ -578,70 +562,6 @@ function validateSecondaryLogin(
578562 } ,
579563 } ,
580564 ] ;
581- // If the primary login isn't validated yet, set the secondary login as the primary login
582- if ( ! loginList ?. [ currentEmail ] . validatedDate ) {
583- successData . push (
584- ...[
585- {
586- onyxMethod : Onyx . METHOD . MERGE ,
587- key : ONYXKEYS . ACCOUNT ,
588- value : {
589- primaryLogin : contactMethod ,
590- } ,
591- } ,
592- {
593- onyxMethod : Onyx . METHOD . MERGE ,
594- key : ONYXKEYS . SESSION ,
595- value : {
596- email : contactMethod ,
597- } ,
598- } ,
599- {
600- onyxMethod : Onyx . METHOD . MERGE ,
601- key : ONYXKEYS . PERSONAL_DETAILS_LIST ,
602- value : {
603- [ currentUserAccountID ] : {
604- login : contactMethod ,
605- displayName : PersonalDetailsUtils . createDisplayName ( contactMethod , currentUserPersonalDetails , formatPhoneNumber ) ,
606- } ,
607- } ,
608- } ,
609- ] ,
610- ) ;
611-
612- for ( const policy of Object . values ( allPolicies ?? { } ) ) {
613- if ( ! policy ) {
614- continue ;
615- }
616-
617- let optimisticPolicyDataValue ;
618-
619- if ( policy . employeeList ) {
620- const currentEmployee = policy . employeeList [ currentEmail ] ;
621- optimisticPolicyDataValue = {
622- employeeList : {
623- [ currentEmail ] : null ,
624- [ contactMethod ] : currentEmployee ,
625- } ,
626- } ;
627- }
628-
629- if ( policy . ownerAccountID === currentUserAccountID ) {
630- optimisticPolicyDataValue = {
631- ...optimisticPolicyDataValue ,
632- owner : contactMethod ,
633- } ;
634- }
635-
636- if ( optimisticPolicyDataValue ) {
637- successData . push ( {
638- onyxMethod : Onyx . METHOD . MERGE ,
639- key : `${ ONYXKEYS . COLLECTION . POLICY } ${ policy . id } ` ,
640- value : optimisticPolicyDataValue ,
641- } ) ;
642- }
643- }
644- }
645565
646566 const failureData : Array < OnyxUpdate < typeof ONYXKEYS . LOGIN_LIST | typeof ONYXKEYS . ACCOUNT | typeof ONYXKEYS . VALIDATE_ACTION_CODE > > = [
647567 {
0 commit comments