Skip to content

Commit 70b3bf9

Browse files
authored
Merge pull request Expensify#64909 from thelullabyy/fix/64452-workspace-chat-still-display-GBR
Expense - Workspace chat still displays GBR in LHN after changing report workspace
2 parents 50b2e22 + f0bb813 commit 70b3bf9

3 files changed

Lines changed: 97 additions & 1 deletion

File tree

src/libs/actions/IOU.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ import {
9696
getTrackExpenseActionableWhisper,
9797
isActionableTrackExpense,
9898
isCreatedAction,
99+
isDeletedAction,
99100
isMoneyRequestAction,
100101
isReportPreviewAction,
101102
} from '@libs/ReportActionsUtils';
@@ -9239,7 +9240,12 @@ function getIOUReportActionToApproveOrPay(chatReport: OnyxEntry<OnyxTypes.Report
92399240
// eslint-disable-next-line deprecation/deprecation
92409241
const policy = getPolicy(iouReport?.policyID);
92419242
const shouldShowSettlementButton = canIOUBePaid(iouReport, chatReport, policy) || canApproveIOU(iouReport, policy);
9242-
return action.childReportID?.toString() !== excludedIOUReportID && action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && shouldShowSettlementButton;
9243+
return (
9244+
action.childReportID?.toString() !== excludedIOUReportID &&
9245+
action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW &&
9246+
shouldShowSettlementButton &&
9247+
!isDeletedAction(action)
9248+
);
92439249
});
92449250
}
92459251

tests/actions/IOUTest.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
canUnapproveIOU,
1515
createDistanceRequest,
1616
deleteMoneyRequest,
17+
getIOUReportActionToApproveOrPay,
1718
initMoneyRequest,
1819
initSplitExpense,
1920
payMoneyRequest,
@@ -6398,4 +6399,81 @@ describe('actions/IOU', () => {
63986399
});
63996400
});
64006401
});
6402+
6403+
describe('getIOUReportActionToApproveOrPay', () => {
6404+
it('should exclude deleted actions', async () => {
6405+
const reportID = '1';
6406+
const policyID = '2';
6407+
const fakePolicy: Policy = {
6408+
...createRandomPolicy(Number(policyID)),
6409+
approvalMode: CONST.POLICY.APPROVAL_MODE.BASIC,
6410+
};
6411+
6412+
const fakeReport: Report = {
6413+
...createRandomReport(Number(reportID)),
6414+
type: CONST.REPORT.TYPE.EXPENSE,
6415+
policyID,
6416+
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
6417+
statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
6418+
managerID: RORY_ACCOUNT_ID,
6419+
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
6420+
};
6421+
const fakeTransaction1: Transaction = {
6422+
...createRandomTransaction(0),
6423+
reportID,
6424+
bank: CONST.EXPENSIFY_CARD.BANK,
6425+
status: CONST.TRANSACTION.STATUS.PENDING,
6426+
};
6427+
const fakeTransaction2: Transaction = {
6428+
...createRandomTransaction(1),
6429+
reportID,
6430+
amount: 27,
6431+
receipt: {
6432+
source: 'test',
6433+
state: CONST.IOU.RECEIPT_STATE.SCAN_FAILED,
6434+
},
6435+
merchant: CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT,
6436+
modifiedMerchant: undefined,
6437+
};
6438+
const fakeTransaction3: Transaction = {
6439+
...createRandomTransaction(2),
6440+
reportID,
6441+
amount: 100,
6442+
};
6443+
6444+
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${fakeReport.reportID}`, fakeReport);
6445+
await Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION}${fakeTransaction1.transactionID}`, fakeTransaction1);
6446+
await Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION}${fakeTransaction2.transactionID}`, fakeTransaction2);
6447+
await Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION}${fakeTransaction3.transactionID}`, fakeTransaction3);
6448+
await Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, fakePolicy);
6449+
await waitForBatchedUpdates();
6450+
6451+
const deletedReportAction = {
6452+
reportActionID: '0',
6453+
actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW,
6454+
created: '2024-08-08 18:70:44.171',
6455+
childReportID: reportID,
6456+
};
6457+
6458+
const MOCK_REPORT_ACTIONS: ReportActions = {
6459+
[deletedReportAction.reportActionID]: deletedReportAction,
6460+
[reportID]: {
6461+
reportActionID: reportID,
6462+
actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW,
6463+
created: '2024-08-08 19:70:44.171',
6464+
childReportID: reportID,
6465+
message: [
6466+
{
6467+
type: 'TEXT',
6468+
text: 'Hello world!',
6469+
},
6470+
],
6471+
},
6472+
};
6473+
6474+
await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${fakeReport.reportID}`, MOCK_REPORT_ACTIONS);
6475+
6476+
expect(getIOUReportActionToApproveOrPay(fakeReport, undefined)).toMatchObject(MOCK_REPORT_ACTIONS[reportID]);
6477+
});
6478+
});
64016479
});

tests/unit/DebugUtilsTest.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,13 +1077,25 @@ describe('DebugUtils', () => {
10771077
reportActionID: '0',
10781078
actionName: CONST.REPORT.ACTIONS.TYPE.CREATED,
10791079
created: '2024-08-08 18:70:44.171',
1080+
message: [
1081+
{
1082+
type: 'TEXT',
1083+
text: 'Hello world!',
1084+
},
1085+
],
10801086
},
10811087
// eslint-disable-next-line @typescript-eslint/naming-convention
10821088
'1': {
10831089
reportActionID: '1',
10841090
actionName: CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW,
10851091
created: '2024-08-08 19:70:44.171',
10861092
childReportID: '2',
1093+
message: [
1094+
{
1095+
type: 'TEXT',
1096+
text: 'Hello world!',
1097+
},
1098+
],
10871099
},
10881100
};
10891101
await Onyx.multiSet({

0 commit comments

Comments
 (0)