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

Follow up: Fix dependency cycle issue #31438

Merged
merged 1 commit into from
Nov 16, 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
22 changes: 20 additions & 2 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import * as defaultWorkspaceAvatars from '@components/Icon/WorkspaceDefaultAvata
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import * as IOU from './actions/IOU';
import * as CurrencyUtils from './CurrencyUtils';
import DateUtils from './DateUtils';
import isReportMessageAttachment from './isReportMessageAttachment';
Expand Down Expand Up @@ -81,6 +80,25 @@ Onyx.connect({
callback: (val) => (loginList = val),
});

let allPolicyTags = {};

Onyx.connect({
key: ONYXKEYS.COLLECTION.POLICY_TAGS,
waitForCollectionCallback: true,
callback: (value) => {
if (!value) {
allPolicyTags = {};
return;
}

allPolicyTags = value;
},
});

function getPolicyTags(policyID) {
return lodashGet(allPolicyTags, `${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, {});
}

function getChatType(report) {
return report ? report.chatType : '';
}
Expand Down Expand Up @@ -1921,7 +1939,7 @@ function getModifiedExpenseMessage(reportAction) {
}
const reportID = lodashGet(reportAction, 'reportID', '');
const policyID = lodashGet(getReport(reportID), 'policyID', '');
const policyTags = IOU.getPolicyTags(policyID);
const policyTags = getPolicyTags(policyID);
const policyTag = PolicyUtils.getTag(policyTags);
const policyTagListName = lodashGet(policyTag, 'name', Localize.translateLocal('common.tag'));

Expand Down
5 changes: 0 additions & 5 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -2951,10 +2951,6 @@ function getIOUReportID(iou, route) {
return lodashGet(route, 'params.reportID') || lodashGet(iou, 'participants.0.reportID', '');
}

function getPolicyTags(policyID) {
return lodashGet(allPolicyTags, `${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, {});
}

export {
createDistanceRequest,
editMoneyRequest,
Expand Down Expand Up @@ -2991,5 +2987,4 @@ export {
replaceReceipt,
detachReceipt,
getIOUReportID,
getPolicyTags,
};
Loading