Skip to content

Commit ba6905b

Browse files
fix: stay on Spend tab after QAB-submitted expense
1 parent 96365e1 commit ba6905b

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

src/pages/iou/request/step/confirmation/getSubmitHandler.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ function canUseDismissModalFastPath(snapshot: SubmitNavigationSnapshot): boolean
6161
* isPreInserted && !isReportPreInserted -> SEARCH_PRE_INSERT
6262
* isReportPreInserted -> REPORT_PRE_INSERT
6363
* canUseDismissModalFastPath() -> DISMISS_MODAL
64-
* isReportInRHP && destinationReportID -> REPORT_IN_RHP_DISMISS
65-
* isFromGlobalCreate && canDismiss -> SEARCH_DISMISS
64+
* isFromGlobalCreate && canDismissFromSearch && isSearchTopmostFullScreen -> SEARCH_DISMISS
65+
* isReportInRHP && destinationReportID && !isSplitRequest -> REPORT_IN_RHP_DISMISS
6666
* else -> DEFAULT
6767
*/
6868
function getSubmitHandler(snapshot: SubmitNavigationSnapshot): SubmitHandler {
@@ -75,12 +75,12 @@ function getSubmitHandler(snapshot: SubmitNavigationSnapshot): SubmitHandler {
7575
if (canUseDismissModalFastPath(snapshot)) {
7676
return SUBMIT_HANDLER.DISMISS_MODAL;
7777
}
78-
if (snapshot.isReportInRHP && snapshot.destinationReportID && !snapshot.isSplitRequest) {
79-
return SUBMIT_HANDLER.REPORT_IN_RHP_DISMISS;
80-
}
8178
if (snapshot.isFromGlobalCreate && snapshot.canDismissFromSearch && snapshot.isSearchTopmostFullScreen) {
8279
return SUBMIT_HANDLER.SEARCH_DISMISS;
8380
}
81+
if (snapshot.isReportInRHP && snapshot.destinationReportID && !snapshot.isSplitRequest) {
82+
return SUBMIT_HANDLER.REPORT_IN_RHP_DISMISS;
83+
}
8484
return SUBMIT_HANDLER.DEFAULT;
8585
}
8686

tests/unit/getSubmitHandlerTest.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,20 @@ describe('getSubmitHandler', () => {
116116
).toBe(SUBMIT_HANDLER.DEFAULT);
117117
});
118118

119+
it('returns SEARCH_DISMISS (not REPORT_IN_RHP_DISMISS) for global create from Search with report in RHP', () => {
120+
expect(
121+
getSubmitHandler(
122+
snap({
123+
isFromGlobalCreate: true,
124+
canDismissFromSearch: true,
125+
isSearchTopmostFullScreen: true,
126+
isReportInRHP: true,
127+
destinationReportID: '456',
128+
}),
129+
),
130+
).toBe(SUBMIT_HANDLER.SEARCH_DISMISS);
131+
});
132+
119133
it('returns DEFAULT when destination report is set but not loaded', () => {
120134
expect(
121135
getSubmitHandler(

0 commit comments

Comments
 (0)