-
Notifications
You must be signed in to change notification settings - Fork 4k
Fix: do not show Expensify Card when not fully set up #57407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e6bf33f
4dde402
37877ee
0503b24
aa0ed86
9155ce9
7b8d704
f84c3fe
5708437
756f932
f89b775
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,15 +8,16 @@ import Text from '@components/Text'; | |
| import TextLink from '@components/TextLink'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import * as AccountingUtils from '@libs/AccountingUtils'; | ||
| import {getConnectionNameFromRouteParam} from '@libs/AccountingUtils'; | ||
| import {isExpensifyCardFullySetUp} from '@libs/CardUtils'; | ||
| import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; | ||
| import Navigation from '@navigation/Navigation'; | ||
| import type {SettingsNavigatorParamList} from '@navigation/types'; | ||
| import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; | ||
| import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; | ||
| import withPolicyConnections from '@pages/workspace/withPolicyConnections'; | ||
| import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; | ||
| import * as Card from '@userActions/Card'; | ||
| import {toggleContinuousReconciliation} from '@userActions/Card'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import ROUTES from '@src/ROUTES'; | ||
|
|
@@ -29,24 +30,24 @@ function CardReconciliationPage({policy, route}: CardReconciliationPageProps) { | |
| const styles = useThemeStyles(); | ||
| const {translate} = useLocalize(); | ||
|
|
||
| const workspaceAccountID = policy?.workspaceAccountID ?? -1; | ||
| const workspaceAccountID = policy?.workspaceAccountID ?? CONST.DEFAULT_NUMBER_ID; | ||
|
|
||
| const [isContinuousReconciliationOn] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`); | ||
| const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); | ||
| const [currentConnectionName] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${workspaceAccountID}`); | ||
| const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); | ||
|
|
||
| const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? 0; | ||
| const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? CONST.DEFAULT_NUMBER_ID; | ||
| const bankAccountTitle = bankAccountList?.[paymentBankAccountID]?.title ?? ''; | ||
|
|
||
| const policyID = policy?.id ?? '-1'; | ||
| const policyID = policy?.id; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need t change this line?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eslint
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/Expensify/App/actions/runs/13524618354/job/37791922234?pr=57407 Do not default string IDs to any value. As I mentioned above - I don't like this rule as we have many occurrences of defaulting to '-1'
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and TS fails, but it's my bad I didn't resolve the conflicts properly |
||
| const {connection} = route.params; | ||
| const connectionName = AccountingUtils.getConnectionNameFromRouteParam(connection) as ConnectionName; | ||
| const connectionName = getConnectionNameFromRouteParam(connection) as ConnectionName; | ||
| const autoSync = !!policy?.connections?.[connectionName]?.config?.autoSync?.enabled; | ||
| const shouldShow = policy?.areExpensifyCardsEnabled && cardSettings?.paymentBankAccountID; | ||
| const shouldShow = isExpensifyCardFullySetUp(policy, cardSettings); | ||
|
|
||
| const toggleContinuousReconciliation = (value: boolean) => { | ||
| Card.toggleContinuousReconciliation(workspaceAccountID, value, connectionName, currentConnectionName); | ||
| const handleToggleContinuousReconciliation = (value: boolean) => { | ||
| toggleContinuousReconciliation(workspaceAccountID, value, connectionName, currentConnectionName); | ||
| if (value) { | ||
| Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_RECONCILIATION_ACCOUNT_SETTINGS.getRoute(policyID, connection)); | ||
| } | ||
|
|
@@ -93,7 +94,7 @@ function CardReconciliationPage({policy, route}: CardReconciliationPageProps) { | |
| switchAccessibilityLabel={translate('workspace.accounting.continuousReconciliation')} | ||
| disabled={!autoSync} | ||
| isActive={!!isContinuousReconciliationOn} | ||
| onToggle={toggleContinuousReconciliation} | ||
| onToggle={handleToggleContinuousReconciliation} | ||
| wrapperStyle={styles.ph5} | ||
| /> | ||
| {!autoSync && ( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.