Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
1dd72aa
fix navigation for different assignees in confirmation flow
twilight2294 Feb 12, 2025
ba7bcf0
fix failing test
twilight2294 Feb 12, 2025
7eb930a
Merge branch 'Expensify:main' into issue/56009
twilight2294 Feb 14, 2025
9da4a6b
Merge branch 'Expensify:main' into issue/56009
twilight2294 Feb 16, 2025
cf36251
Merge branch 'Expensify:main' into issue/56009
twilight2294 Feb 18, 2025
60a1c89
use a `useRef` to store the first value of the card assignee email
twilight2294 Feb 18, 2025
4722cfd
make use of `useState`
twilight2294 Feb 18, 2025
867522c
move `useRef` usage to `AssignCardFeedPage`
twilight2294 Feb 18, 2025
f5a57e5
Merge branch 'issue/56009' of https://github.com/twilight2294/App int…
twilight2294 Feb 18, 2025
9a7fa81
fix named imports `ESLint`
twilight2294 Feb 18, 2025
8f34ad6
remove unnecessary console log
twilight2294 Feb 18, 2025
3e49e20
Merge branch 'Expensify:main' into issue/56009
twilight2294 Feb 20, 2025
85638f4
Merge branch 'Expensify:main' into issue/56009
twilight2294 Feb 21, 2025
a177e5c
Revert all changes after cf362518984492f51112009286e966b775319433 , e…
twilight2294 Feb 21, 2025
baad25d
update route to add new param `workspaceMemberAccountID`
twilight2294 Feb 21, 2025
57f24c1
fix eslint
twilight2294 Feb 21, 2025
f328608
fix lint
twilight2294 Feb 21, 2025
e15accf
gracefully exit if value if undefined
twilight2294 Feb 21, 2025
e15b3e1
Merge branch 'Expensify:main' into issue/56009
twilight2294 Feb 23, 2025
cad4e37
make use of `useRef`
twilight2294 Feb 23, 2025
7b1092b
suppress compiler useRef error
twilight2294 Feb 23, 2025
b837f39
Merge branch 'Expensify:main' into issue/56009
twilight2294 Feb 26, 2025
b453b3c
enable and disable es-lint only once
twilight2294 Feb 26, 2025
e4bb3ee
update navigation logic of expensify cards if different assingee is s…
twilight2294 Feb 26, 2025
1b22dc7
fix prettier
twilight2294 Feb 26, 2025
767d2f0
update to conditional navigation logic
twilight2294 Feb 26, 2025
78489cd
fix lint
twilight2294 Feb 26, 2025
9013779
fix compiler error
twilight2294 Feb 26, 2025
d48eff5
rearrange es-lint silencers
twilight2294 Feb 27, 2025
71af3fd
Merge branch 'Expensify:main' into issue/56009
twilight2294 Mar 12, 2025
466be32
Merge branch 'Expensify:main' into issue/56009
twilight2294 Mar 12, 2025
04acbc2
Merge branch 'main' into issue/56009
twilight2294 Mar 27, 2025
7a4a770
add UI navigation test for company cards assignment navigation logic
twilight2294 Mar 27, 2025
9abee4a
fix double import issue
twilight2294 Mar 27, 2025
bc1535f
remove unused variables
twilight2294 Mar 27, 2025
4a5826b
fix navigation logic and supress the useRef error properly
twilight2294 Mar 27, 2025
bfbd25d
Merge branch 'issue/56009' of https://github.com/twilight2294/App int…
twilight2294 Mar 27, 2025
7ab5f8b
fix navigation test to use goBack when assignee doesn't change
twilight2294 Mar 27, 2025
024f2af
Merge branch 'Expensify:main' into issue/56009
twilight2294 Mar 30, 2025
6b5a3d4
fix navigation
twilight2294 Mar 30, 2025
b8e2685
fix failing test
twilight2294 Mar 31, 2025
790cb86
Merge branch 'Expensify:main' into issue/56009
twilight2294 Apr 7, 2025
25e1ad4
Merge branch 'Expensify:main' into issue/56009
twilight2294 Apr 9, 2025
72465d9
Merge branch 'Expensify:main' into issue/56009
twilight2294 Apr 18, 2025
43ee59d
Merge branch 'Expensify:main' into issue/56009
twilight2294 Apr 23, 2025
6a8909c
Merge branch 'Expensify:main' into issue/56009
twilight2294 Apr 24, 2025
2a58fac
fix navigation issue
twilight2294 Apr 24, 2025
fd28a68
Merge branch 'Expensify:main' into issue/56009
twilight2294 Apr 25, 2025
c2d03a7
create useInitial hook
twilight2294 Apr 25, 2025
3a74b47
fix eslint
twilight2294 Apr 25, 2025
982696b
Apply suggestions from code review
twilight2294 Apr 25, 2025
9211049
Merge branch 'Expensify:main' into issue/56009
twilight2294 May 12, 2025
a76d803
revert force replace
twilight2294 May 12, 2025
44adf9d
Merge branch 'Expensify:main' into issue/56009
twilight2294 May 24, 2025
aa686f8
fix hardware back button behaviour on expensify cards page
twilight2294 May 25, 2025
68137f9
fix hardware back button behaviour on company cards apge
twilight2294 May 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ const CONST = {
RIGHT: 'right',
},

ASSIGN_CARD_BUTTON_TEST_ID: 'assignCardButtonTestID',
// Sizes needed for report empty state background image handling
EMPTY_STATE_BACKGROUND: {
ASPECT_RATIO: 3.72,
Expand Down
20 changes: 20 additions & 0 deletions src/hooks/useInitial.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {useRef} from 'react';

/**
* A hook that returns the initial non-undefined value of a variable.
*
* @param value The value to evaluate.
* @returns The first non-undefined value passed to the hook.
*/
function useInitial<T>(value: T | undefined): T | undefined {
const initialValueRef = useRef<T | undefined>();
/* eslint-disable react-compiler/react-compiler */
if (initialValueRef.current === undefined && value !== undefined) {
initialValueRef.current = value;
}

return initialValueRef.current;
/* eslint-enable react-compiler/react-compiler */
Comment thread
twilight2294 marked this conversation as resolved.
Resolved
}

export default useInitial;
8 changes: 6 additions & 2 deletions src/pages/workspace/WorkspacePageWithSections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import HeaderWithBackButton from '@components/HeaderWithBackButton';
import type HeaderWithBackButtonProps from '@components/HeaderWithBackButton/types';
import ScreenWrapper from '@components/ScreenWrapper';
import ScrollViewWithContext from '@components/ScrollViewWithContext';
import useHandleBackButton from '@hooks/useHandleBackButton';
import useNetwork from '@hooks/useNetwork';
import usePrevious from '@hooks/usePrevious';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
Expand Down Expand Up @@ -174,17 +175,20 @@ function WorkspacePageWithSections({
const handleOnBackButtonPress = () => {
if (onBackButtonPress) {
onBackButtonPress();
return;
return true;
}

if (backButtonRoute) {
Navigation.goBack(backButtonRoute);
return;
return true;
}

Navigation.popToSidebar();
return true;
};

useHandleBackButton(handleOnBackButtonPress);

return (
<ScreenWrapper
enableEdgeToEdgeBottomSafeAreaPadding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {useEffect} from 'react';
import {useOnyx} from 'react-native-onyx';
import DelegateNoAccessWrapper from '@components/DelegateNoAccessWrapper';
import ScreenWrapper from '@components/ScreenWrapper';
import useInitial from '@hooks/useInitial';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import type {SettingsNavigatorParamList} from '@navigation/types';
import BankConnection from '@pages/workspace/companyCards/BankConnection';
Expand All @@ -21,13 +22,15 @@ import TransactionStartDateStep from './TransactionStartDateStep';
type AssignCardFeedPageProps = PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.COMPANY_CARDS_ASSIGN_CARD> & WithPolicyAndFullscreenLoadingProps;

function AssignCardFeedPage({route, policy}: AssignCardFeedPageProps) {
const [assignCard] = useOnyx(ONYXKEYS.ASSIGN_CARD);
const [assignCard] = useOnyx(ONYXKEYS.ASSIGN_CARD, {canBeMissing: true});
const currentStep = assignCard?.currentStep;

const feed = decodeURIComponent(route.params?.feed) as CompanyCardFeed;
const backTo = route.params?.backTo;
const policyID = policy?.id;
const [isActingAsDelegate] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => !!account?.delegatedAccess?.delegate});
const [isActingAsDelegate] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => !!account?.delegatedAccess?.delegate, canBeMissing: true});
const firstAssigneeEmail = useInitial(assignCard?.data?.email);
const shouldUseBackToParam = !firstAssigneeEmail || firstAssigneeEmail === assignCard?.data?.email;

useEffect(() => {
return () => {
Expand Down Expand Up @@ -83,7 +86,7 @@ function AssignCardFeedPage({route, policy}: AssignCardFeedPageProps) {
return (
<ConfirmationStep
policyID={policyID}
backTo={backTo}
backTo={shouldUseBackToParam ? backTo : undefined}
/>
);
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ function ConfirmationStep({policyID, backTo}: ConfirmationStepProps) {
if (!assignCard?.isAssigned) {
return;
}
Navigation.goBack(backTo ?? ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(policyID));

if (backTo) {
Navigation.goBack(backTo);
} else {
Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(policyID));
Comment thread
twilight2294 marked this conversation as resolved.
Resolved
}
InteractionManager.runAfterInteractions(() => clearAssignCardStepAndData());
}, [assignCard, backTo, policyID]);

Expand Down Expand Up @@ -128,6 +133,7 @@ function ConfirmationStep({policyID, backTo}: ConfirmationStepProps) {
isLoading={assignCard?.isAssigning}
style={styles.w100}
onPress={submit}
testID={CONST.ASSIGN_CARD_BUTTON_TEST_ID}
text={translate('workspace.companyCards.assignCard')}
/>
</OfflineWithFeedback>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import ScrollView from '@components/ScrollView';
import SearchBar from '@components/SearchBar';
import useBottomSafeSafeAreaPaddingStyle from '@hooks/useBottomSafeSafeAreaPaddingStyle';
import useExpensifyCardFeeds from '@hooks/useExpensifyCardFeeds';
import useHandleBackButton from '@hooks/useHandleBackButton';
import useLocalize from '@hooks/useLocalize';
import usePolicy from '@hooks/usePolicy';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
Expand Down Expand Up @@ -146,6 +147,13 @@ function WorkspaceExpensifyCardListPage({route, cardsList, fundID}: WorkspaceExp

const bottomSafeAreaPaddingStyle = useBottomSafeSafeAreaPaddingStyle();

const handleBackButtonPress = () => {
Navigation.popToSidebar();
return true;
};

useHandleBackButton(handleBackButtonPress);

return (
<ScreenWrapper
enableEdgeToEdgeBottomSafeAreaPadding
Expand All @@ -159,7 +167,7 @@ function WorkspaceExpensifyCardListPage({route, cardsList, fundID}: WorkspaceExp
shouldUseHeadlineHeader
title={translate('workspace.common.expensifyCard')}
shouldShowBackButton={shouldUseNarrowLayout}
onBackButtonPress={Navigation.popToSidebar}
onBackButtonPress={handleBackButtonPress}
>
{!shouldShowSelector && !shouldUseNarrowLayout && isBankAccountVerified && getHeaderButtons()}
</HeaderWithBackButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ function ConfirmationStep({policyID, backTo}: ConfirmationStepProps) {
if (!isSuccessful) {
return;
}
Navigation.goBack(backTo ?? ROUTES.WORKSPACE_EXPENSIFY_CARD.getRoute(policyID));
if (backTo) {
Navigation.goBack(backTo);
} else {
Navigation.navigate(ROUTES.WORKSPACE_EXPENSIFY_CARD.getRoute(policyID));
Comment thread
twilight2294 marked this conversation as resolved.
Resolved
Comment on lines +61 to +64

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@s77rt the problem you mentioned is because, when we navigate we still have the assignee screen modal in the stack which will get triggered when we go back via the back button:

I tried using goBack with {shouldPopToTop: true} and it fixes the issue on small screen but on large screens goBack doesn't work as we change the tab to expensify cards, a solution i thought of is to remove all the previous stack before navigation, trying it out now, let me know if you have any ideas

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump @s77rt , i'm still looking but no new leads

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what is the best option here. I could see that this is a minor bug but even the original issue is a minor bug thus I don't think we want to "switch" bugs. Maybe we should explore a different solution at this point

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah based on the video I agree with @s77rt

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will investigate a potential solution over the weekend

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried some solutions but didn't work, one solution is to remove the stack of the assignment screen and have the intial workspace page screen in the stack, testing that today

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this hook used to handle hardware back button: https://github.com/Expensify/App/blob/main/src/hooks/useHandleBackButton/index.android.ts#L6

Trying to use it now

@twilight2294 twilight2294 May 25, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@s77rt can you please retest this PR, I fixed the bug

@yuwenmemon i think this PR is now ready to get merged

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen_recording_20250525_161514.mp4

@s77rt s77rt May 25, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not able to test due to build errors but the added code lgtm and the video looks right

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have double workspace company cards pages after navigation here causing this issue #63116

}
Comment on lines +61 to +65

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is missing from src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added 👍


Comment on lines +61 to +66

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, because we will be navigating to a central pane and not going back, the going back will only close the RHP

clearIssueNewCardFlow(policyID);
}, [backTo, policyID, isSuccessful]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {useEffect} from 'react';
import {useOnyx} from 'react-native-onyx';
import DelegateNoAccessWrapper from '@components/DelegateNoAccessWrapper';
import ScreenWrapper from '@components/ScreenWrapper';
import useInitial from '@hooks/useInitial';
import {startIssueNewCardFlow} from '@libs/actions/Card';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
Expand All @@ -23,11 +24,12 @@ type IssueNewCardPageProps = WithPolicyAndFullscreenLoadingProps & PlatformStack

function IssueNewCardPage({policy, route}: IssueNewCardPageProps) {
const policyID = policy?.id;
const [issueNewCard] = useOnyx(`${ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD}${policyID}`);
const [issueNewCard] = useOnyx(`${ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD}${policyID}`, {canBeMissing: true});
const {currentStep} = issueNewCard ?? {};
const backTo = route?.params?.backTo;

const [isActingAsDelegate] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => !!account?.delegatedAccess?.delegate});
const firstAssigneeEmail = useInitial(issueNewCard?.data?.assigneeEmail);
const shouldUseBackToParam = !firstAssigneeEmail || firstAssigneeEmail === issueNewCard?.data?.assigneeEmail;
const [isActingAsDelegate] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => !!account?.delegatedAccess?.delegate, canBeMissing: true});

useEffect(() => {
startIssueNewCardFlow(policyID);
Expand All @@ -49,7 +51,7 @@ function IssueNewCardPage({policy, route}: IssueNewCardPageProps) {
return (
<ConfirmationStep
policyID={policyID}
backTo={backTo}
backTo={shouldUseBackToParam ? backTo : undefined}
/>
);
default:
Expand Down
Loading