@@ -1300,12 +1300,11 @@ function isCorrectSearchUserName(displayName?: string) {
13001300}
13011301
13021302function createTypeMenuSections (
1303- session : OnyxTypes . Session | undefined ,
1303+ currentUserLogin : string | undefined ,
1304+ currentUserAccountID : number | undefined ,
13041305 feeds : OnyxCollection < OnyxTypes . CardFeeds > ,
13051306 policies : OnyxCollection < OnyxTypes . Policy > = { } ,
13061307) : SearchTypeMenuSection [ ] {
1307- const email = session ?. email ;
1308-
13091308 // Start building the sections by requiring the following sections to always be present
13101309 const typeMenuSections : SearchTypeMenuSection [ ] = [
13111310 {
@@ -1354,7 +1353,7 @@ function createTypeMenuSections(
13541353 }
13551354
13561355 const reimburser = policy . reimburser ;
1357- const isReimburser = reimburser === email ;
1356+ const isReimburser = reimburser === currentUserLogin ;
13581357 const isAdmin = policy . role === CONST . POLICY . ROLE . ADMIN ;
13591358
13601359 if ( policy . reimbursementChoice === CONST . POLICY . REIMBURSEMENT_CHOICES . REIMBURSEMENT_YES ) {
@@ -1369,34 +1368,34 @@ function createTypeMenuSections(
13691368 } ) ;
13701369
13711370 const showApproveSuggestion = Object . values ( policies ) . some ( ( policy ) : policy is OnyxTypes . Policy => {
1372- if ( ! policy || ! email || ! isPaidGroupPolicy ( policy ) ) {
1371+ if ( ! policy || ! currentUserLogin || ! isPaidGroupPolicy ( policy ) ) {
13731372 return false ;
13741373 }
13751374
13761375 if ( policy . approvalMode === CONST . POLICY . APPROVAL_MODE . OPTIONAL ) {
13771376 return false ;
13781377 }
13791378
1380- const isPolicyApprover = policy . approver === email ;
1379+ const isPolicyApprover = policy . approver === currentUserLogin ;
13811380 const isSubmittedTo = Object . values ( policy . employeeList ?? { } ) . some ( ( employee ) => {
1382- return employee . submitsTo === email || employee . forwardsTo === email ;
1381+ return employee . submitsTo === currentUserLogin || employee . forwardsTo === currentUserLogin ;
13831382 } ) ;
13841383
13851384 return isPolicyApprover || isSubmittedTo ;
13861385 } ) ;
13871386
13881387 const showExportSuggestion = Object . values ( policies ) . some ( ( policy ) : policy is OnyxTypes . Policy => {
1389- if ( ! policy || ! email ) {
1388+ if ( ! policy || ! currentUserLogin ) {
13901389 return false ;
13911390 }
13921391
1393- return policy . exporter === email ;
1392+ return policy . exporter === currentUserLogin ;
13941393 } ) ;
13951394 // We suggest specific filters for users based on their access in specific policies. Show the todo section
13961395 // only if any of these items are available
13971396 const showTodoSection = showSubmitSuggestion || showApproveSuggestion || showPaySuggestion || showExportSuggestion ;
13981397
1399- if ( showTodoSection && session ) {
1398+ if ( showTodoSection && currentUserAccountID ) {
14001399 const section : SearchTypeMenuSection = {
14011400 translationPath : 'common.todo' ,
14021401 menuItems : [ ] ,
@@ -1422,7 +1421,7 @@ function createTypeMenuSections(
14221421 buttonAction : ( ) => {
14231422 interceptAnonymousUser ( ( ) => {
14241423 const activePolicy = getActivePolicy ( ) ;
1425- const personalDetails = getPersonalDetailsForAccountID ( session . accountID ) as OnyxTypes . PersonalDetails ;
1424+ const personalDetails = getPersonalDetailsForAccountID ( currentUserAccountID ) as OnyxTypes . PersonalDetails ;
14261425
14271426 let workspaceIDForReportCreation : string | undefined ;
14281427
@@ -1454,7 +1453,7 @@ function createTypeMenuSections(
14541453 type : CONST . SEARCH . DATA_TYPES . EXPENSE ,
14551454 groupBy : CONST . SEARCH . GROUP_BY . REPORTS ,
14561455 status : CONST . SEARCH . STATUS . EXPENSE . DRAFTS ,
1457- from : [ `${ session . accountID } ` ] ,
1456+ from : [ `${ currentUserAccountID } ` ] ,
14581457 } ) ;
14591458 return queryString ;
14601459 } ,
@@ -1477,7 +1476,7 @@ function createTypeMenuSections(
14771476 type : CONST . SEARCH . DATA_TYPES . EXPENSE ,
14781477 groupBy : CONST . SEARCH . GROUP_BY . REPORTS ,
14791478 action : CONST . SEARCH . ACTION_FILTERS . APPROVE ,
1480- to : [ `${ session . accountID } ` ] ,
1479+ to : [ `${ currentUserAccountID } ` ] ,
14811480 } ) ;
14821481 return queryString ;
14831482 } ,
@@ -1501,7 +1500,7 @@ function createTypeMenuSections(
15011500 groupBy : CONST . SEARCH . GROUP_BY . REPORTS ,
15021501 action : CONST . SEARCH . ACTION_FILTERS . PAY ,
15031502 reimbursable : CONST . SEARCH . BOOLEAN . YES ,
1504- payer : session . accountID ?. toString ( ) ,
1503+ payer : currentUserAccountID ?. toString ( ) ,
15051504 } ) ;
15061505 return queryString ;
15071506 } ,
@@ -1524,7 +1523,7 @@ function createTypeMenuSections(
15241523 type : CONST . SEARCH . DATA_TYPES . EXPENSE ,
15251524 groupBy : CONST . SEARCH . GROUP_BY . REPORTS ,
15261525 action : CONST . SEARCH . ACTION_FILTERS . EXPORT ,
1527- exporter : [ `${ session . accountID } ` ] ,
1526+ exporter : [ `${ currentUserAccountID } ` ] ,
15281527 exportedOn : CONST . SEARCH . DATE_PRESETS . NEVER ,
15291528 } ) ;
15301529 return queryString ;
0 commit comments