Skip to content

Commit

Permalink
Merge pull request #31438 from GItGudRatio/fix/dependency-cycle
Browse files Browse the repository at this point in the history
Follow up: Fix dependency cycle issue
  • Loading branch information
lakchote authored Nov 16, 2023
2 parents ead926e + 37b438c commit 6a8a02f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
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 @@ -82,6 +81,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 @@ -1922,7 +1940,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,
};

0 comments on commit 6a8a02f

Please sign in to comment.