Skip to content
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
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7477,7 +7477,7 @@ function getPolicyExpenseChat(ownerAccountID: number | undefined, policyID: stri
return false;
}

return report.policyID === policyID && isPolicyExpenseChat(report) && report.ownerAccountID === ownerAccountID;
return report.policyID === policyID && isPolicyExpenseChat(report) && !isThread(report) && report.ownerAccountID === ownerAccountID;
});
}

Expand Down
28 changes: 28 additions & 0 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
getIconsForParticipants,
getInvoiceChatByParticipants,
getMostRecentlyVisitedReport,
getPolicyExpenseChat,
getQuickActionDetails,
getReportIDFromLink,
getReportName,
Expand Down Expand Up @@ -1919,6 +1920,33 @@ describe('ReportUtils', () => {
});
});

describe('getPolicyExpenseChat', () => {
it('should return the correct policy expense chat when we have a task report is the child of this report', async () => {
const policyExpenseChat: Report = {
...createRandomReport(11),
ownerAccountID: 1,
policyID: '1',
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
type: CONST.REPORT.TYPE.CHAT,
};

const taskReport: Report = {
...createRandomReport(10),
ownerAccountID: 1,
policyID: '1',
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
type: CONST.REPORT.TYPE.TASK,
parentReportID: policyExpenseChat.reportID,
parentReportActionID: '1',
};

await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${taskReport.reportID}`, taskReport);
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${policyExpenseChat.reportID}`, policyExpenseChat);

expect(getPolicyExpenseChat(1, '1')?.reportID).toBe(policyExpenseChat.reportID);
});
});

describe('getApprovalChain', () => {
describe('submit and close policy', () => {
it('should return empty array', () => {
Expand Down