Skip to content

Commit 8814c34

Browse files
authored
Merge pull request Expensify#88979 from software-mansion-labs/jakubkalinski0/Fix_user_is_navigated_to_the_WS_chat_when_created_expense_in_Spend_via_Quick_Action
Fix: user is incorrectly navigated to the WS chat when created expense in Spend via Quick Action
2 parents 1e81a96 + e93ac59 commit 8814c34

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)