Skip to content

Commit 309bc78

Browse files
authored
Merge pull request Expensify#66054 from etCoderDysto/change_workspace
fix: Nothing happens when submitter deletes own expense and clicks Change workspace
2 parents 836eebd + f87ccb0 commit 309bc78

2 files changed

Lines changed: 59 additions & 1 deletion

File tree

src/libs/ReportActionsUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1839,7 +1839,7 @@ function hasRequestFromCurrentAccount(reportID: string | undefined, currentAccou
18391839
return false;
18401840
}
18411841

1842-
return reportActions.some((action) => action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && action.actorAccountID === currentAccountID);
1842+
return reportActions.some((action) => action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && action.actorAccountID === currentAccountID && !isDeletedAction(action));
18431843
}
18441844

18451845
/**

tests/unit/ReportActionsUtilsTest.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,64 @@ describe('ReportActionsUtils', () => {
763763
});
764764
});
765765

766+
describe('hasRequestFromCurrentAccount', () => {
767+
const currentUserAccountID = 1242;
768+
const deletedIOUReportID = '2';
769+
const activeIOUReportID = '3';
770+
771+
const deletedIOUReportAction: ReportAction = {
772+
...LHNTestUtils.getFakeReportAction(),
773+
reportActionID: '22',
774+
actionName: CONST.REPORT.ACTIONS.TYPE.IOU,
775+
actorAccountID: currentUserAccountID,
776+
message: [
777+
{
778+
deleted: '2025-07-15 09:06:16.568',
779+
html: '',
780+
isDeletedParentAction: false,
781+
isEdited: true,
782+
text: '',
783+
type: 'COMMENT',
784+
},
785+
],
786+
};
787+
788+
const activeIOUReportAction: ReportAction = {
789+
...LHNTestUtils.getFakeReportAction(),
790+
reportActionID: '33',
791+
actionName: CONST.REPORT.ACTIONS.TYPE.IOU,
792+
actorAccountID: currentUserAccountID,
793+
message: [
794+
{
795+
deleted: '',
796+
html: '$87.00 expense',
797+
isDeletedParentAction: false,
798+
isEdited: true,
799+
text: '',
800+
type: 'COMMENT',
801+
},
802+
],
803+
};
804+
805+
beforeEach(() => {
806+
Onyx.multiSet({
807+
[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${deletedIOUReportID}`]: {[deletedIOUReportAction.reportActionID]: deletedIOUReportAction},
808+
[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${activeIOUReportID}`]: {[activeIOUReportAction.reportActionID]: activeIOUReportAction},
809+
} as unknown as KeyValueMapping);
810+
return waitForBatchedUpdates();
811+
});
812+
813+
it('should return false for a deleted IOU report action', () => {
814+
const result = ReportActionsUtils.hasRequestFromCurrentAccount(deletedIOUReportID, currentUserAccountID);
815+
expect(result).toBe(false);
816+
});
817+
818+
it('should return true for an active IOU report action', () => {
819+
const result = ReportActionsUtils.hasRequestFromCurrentAccount(activeIOUReportID, currentUserAccountID);
820+
expect(result).toBe(true);
821+
});
822+
});
823+
766824
describe('getLastVisibleAction', () => {
767825
it('should return the last visible action for a report', () => {
768826
const report: Report = {

0 commit comments

Comments
 (0)