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
3 changes: 1 addition & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5425,11 +5425,10 @@ function getReasonAndReportActionThatRequiresAttention({
// A report whose only expenses are pending Expensify Card transactions can't be actioned until they post, so it
// shouldn't demand attention even when the chat still carries an outstanding-child flag.
const hasStaleChildRequest = isTripRoom(optionOrReport) && (optionOrReport.transactionCount ?? 0) === 0;
// The bare outstanding-child flag only asks the owner to add expenses to their open report, so it is ignored when the current user cannot create expenses on that workspace.
// The bare outstanding-child flag on an open report owned by the current user only asks them to add expenses or submit it, so it is ignored when they cannot create or submit expenses on that workspace.
const isBareOutstandingChildIgnorable =
!iouReportActionToApproveOrPay?.reportActionID &&
isOpenExpenseReport(iouReport) &&
(iouReport?.transactionCount ?? 0) === 0 &&
iouReport?.ownerAccountID === currentUserAccountID &&
!canCreateExpensesOnPolicy(resolvePolicy(iouReport?.policyID), currentUserLogin);
const hasValidIOUAction =
Expand Down
41 changes: 41 additions & 0 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4738,6 +4738,47 @@ describe('ReportUtils', () => {
expect(requiresAttentionFromCurrentUser(policyExpenseChat, currentUserEmail, currentUserAccountID, undefined)).toBe(false);
});

it('returns false when the outstanding child is the member own open report with expenses on a workspace they cannot create expenses on', async () => {
// Given the member's own open report with expenses on an approve-only workspace
// When the LHN checks whether their workspace chat needs attention
// Then the outstanding-child flag alone does not show the GBR, since the member cannot submit their own report on that workspace
const expenseReportID = '7103';
const expenseReport = {
...LHNTestUtils.getFakeReport(),
reportID: expenseReportID,
policyID: '1',
ownerAccountID: currentUserAccountID,
managerID: currentUserAccountID,
type: CONST.REPORT.TYPE.EXPENSE,
stateNum: CONST.REPORT.STATE_NUM.OPEN,
statusNum: CONST.REPORT.STATUS_NUM.OPEN,
transactionCount: 1,
total: -1000,
};

const policyExpenseChat = {
...createPolicyExpenseChat(103, true),
policyID: '1',
ownerAccountID: currentUserAccountID,
hasOutstandingChildRequest: true,
iouReportID: expenseReportID,
};

const transaction = {
...createRandomTransaction(7103),
transactionID: '7103',
reportID: expenseReportID,
status: CONST.TRANSACTION.STATUS.POSTED,
};

await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}1`, {role: CONST.POLICY.ROLE.APPROVE_ONLY});
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${expenseReportID}`, expenseReport);
await Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`, transaction);
await waitForBatchedUpdates();

expect(requiresAttentionFromCurrentUser(policyExpenseChat, currentUserEmail, currentUserAccountID, undefined)).toBe(false);
});

it('returns true when the outstanding child is the member own empty report on a workspace they can create expenses on', async () => {
// Given the member's own open, empty report on a workspace where they are a regular member
// When the LHN checks whether their workspace chat needs attention
Expand Down
Loading