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

fix to getAccountIDForLogin applied #20818

Closed
Closed
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
8 changes: 6 additions & 2 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import _ from 'underscore';
import Str from 'expensify-common/lib/str';
import lodashGet from 'lodash/get';
import lodashFind from 'lodash/find';
import lodashKeys from 'lodash/keys';
Comment on lines +4 to +5
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import lodashFind from 'lodash/find';
import lodashKeys from 'lodash/keys';

Suggestion Follow up

import lodashIntersection from 'lodash/intersection';
import Onyx from 'react-native-onyx';
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
Expand Down Expand Up @@ -825,10 +827,12 @@ function getPersonalDetailsForAccountID(accountID) {
* Gets the accountID for a login by looking in the ONYXKEYS.PERSONAL_DETAILS Onyx key (stored in the local variable, allPersonalDetails). If it doesn't exist in Onyx,
* then an empty string is returned.
* @param {String} login
* @returns {String}
* @returns {Number}
*/
function getAccountIDForLogin(login) {
return lodashGet(allPersonalDetails, [login, 'accountID'], '');
const keys = lodashKeys(allPersonalDetails);
const result = lodashFind(keys, (key) => allPersonalDetails[key].login === login) || '0';
return Number(result);
Comment on lines +833 to +835
Copy link
Contributor

@fedirjh fedirjh Jun 15, 2023

Choose a reason for hiding this comment

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

Suggested change
const keys = lodashKeys(allPersonalDetails);
const result = lodashFind(keys, (key) => allPersonalDetails[key].login === login) || '0';
return Number(result);
const accountID = _.findKey(allPersonalDetails, {login}) || '0';
return Number(accountID);

We can simplify this block , we can use underscore findKey .

Copy link
Contributor

Choose a reason for hiding this comment

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

This seemed to work well for me too 👍

}

/**
Expand Down