You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2025-02-18] Refactor actions in Travel.tsx #55755
The actions from Travel break the App guidelines and perform navigation, which should happen only from the views. They also break the naming convention for the acronyms.
Solution
Refactor the actions to comply with the App code style and guidelines.
🚨 Edited by proposal-police: This proposal was edited at 2025-01-25 01:14:15 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Refactor actions in Travel.tsx
What is the root cause of that problem?
Refactor
What changes do you think we should make in order to solve the problem?
We should remove bookATrip from TripReservation Utils.
Create a new function bookATrip inside EmptySearchView and ManageTrips.
const[account]=useOnyx(ONYXKEYS.ACCOUNT);const[activePolicyID]=useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);const[travelSettings]=useOnyx(ONYXKEYS.NVP_TRAVEL_SETTINGS);const[isSingleNewDotEntry]=useOnyx(ONYXKEYS.IS_SINGLE_NEW_DOT_ENTRY);constbookATrip=useCallback(()=>{if(Str.isSMSLogin(account?.primaryLogin??'')){setCTAErrorMessage(translate('travel.phoneError'));return;}constpolicy=PolicyUtils.getPolicy(activePolicyID);if(isEmptyObject(policy?.address)){Navigation.navigate(ROUTES.WORKSPACE_PROFILE_ADDRESS.getRoute(activePolicyID,Navigation.getActiveRoute()));return;}if(!travelSettings?.hasAcceptedTerms){Navigation.navigate(ROUTES.TRAVEL_TCS);return;}if(ctaErrorMessage){setCTAErrorMessage('');}Link.openTravelDotLink(activePolicyID)?.then(()=>{if(!NativeModules.HybridAppModule||!isSingleNewDotEntry){return;}Log.info('[HybridApp] Returning to OldDot after opening TravelDot');NativeModules.HybridAppModule.closeReactNativeApp(false,false);})?.catch(()=>{setCTAErrorMessage(translate('travel.errorMessage'));});},[account?.primaryLogin,activePolicyID,ctaErrorMessage,isSingleNewDotEntry,translate,travelSettings?.hasAcceptedTerms]);
Replace the old bookATrip function with the new one inside EmptySearchView and ManageTrips.
Update setCtaErrorMessage to setCTAErrorMessage in both components.
// In EmptySearchView and same should be done in other component.buttons: [{buttonText: translate('search.searchResults.emptyTripResults.buttonText'),buttonAction: ()=>{if(isEmptyObject(policy?.address)){Navigation.navigate(ROUTES.WORKSPACE_PROFILE_ADDRESS.getRoute(activePolicyID,Navigation.getActiveRoute()));return;}if(!travelSettings?.hasAcceptedTerms){Navigation.navigate(ROUTES.TRAVEL_TCS);return;}TripsResevationUtils.bookATrip(translate,setCtaErrorMessage,ctaErrorMessage);},success: true,},],
If we are going with this option then we also need to change setCtaErrorMessage param to setCTAErrorMessage.
⚠️@Krishna2323 Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.95-6 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
@cristipaval@strepanier03@cristipaval The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
Activity
melvin-bot commentedon Jan 24, 2025
Triggered auto assignment to @strepanier03 (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.Krishna2323 commentedon Jan 25, 2025
🚨 Edited by proposal-police: This proposal was edited at 2025-01-25 01:14:15 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Refactor actions in Travel.tsx
What is the root cause of that problem?
Refactor
What changes do you think we should make in order to solve the problem?
bookATripfromTripReservationUtils.bookATripinsideEmptySearchViewandManageTrips.bookATripfunction with the new one insideEmptySearchViewandManageTrips.setCtaErrorMessagetosetCTAErrorMessagein both components.App/src/pages/Search/EmptySearchView.tsx
Line 64 in b59f23b
App/src/pages/Travel/ManageTrips.tsx
Line 38 in b59f23b
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
NA
What alternative solutions did you explore?
bookATripand add that in the UI component before we callbookATrip.App/src/libs/TripReservationUtils.ts
Lines 103 to 111 in b59f23b
setCtaErrorMessageparam tosetCTAErrorMessage.App/src/libs/TripReservationUtils.ts
Line 98 in b59f23b
github-actions commentedon Jan 25, 2025
Krishna2323 commentedon Jan 25, 2025
PROPOSAL UPDATED
cristipaval commentedon Jan 27, 2025
This isn't external, at least for now. I'll come to this once I get the original PR merged.
melvin-bot commentedon Feb 6, 2025
@strepanier03, @cristipaval Whoops! This issue is 2 days overdue. Let's get this updated quick!
cristipaval commentedon Feb 6, 2025
This is merged. Closing, it was part of the PR that fixed an App issue
[-]Refactor actions in Travel.tsx[/-][+][Due for payment 2025-02-18] Refactor actions in Travel.tsx[/+]melvin-bot commentedon Feb 11, 2025
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Feb 11, 2025
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.95-6 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2025-02-18. 🎊
melvin-bot commentedon Feb 11, 2025
@cristipaval @strepanier03 @cristipaval The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]