Skip to content
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

Remove outdated conditions #42883

Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyConne
const {translate} = useLocalize();
const styles = useThemeStyles();
const policyID = policy?.id ?? '';
const {syncLocations, reimbursableExpensesAccount, reimbursableExpensesExportDestination, errorFields, syncTax, pendingFields} = policy?.connections?.quickbooksOnline?.config ?? {};
const isLocationEnabled = Boolean(syncLocations && syncLocations !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE);
const isTaxesEnabled = Boolean(syncTax);
const shouldShowTaxError = isTaxesEnabled && reimbursableExpensesExportDestination === CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.JOURNAL_ENTRY;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will never be true.

  • If taxes are enabled you can't select journal entity
  • if journal entity is selected you can't enable taxes

const shouldShowLocationError = isLocationEnabled && reimbursableExpensesExportDestination !== CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.JOURNAL_ENTRY;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same reasoning ^

const hasErrors = Boolean(errorFields?.reimbursableExpensesExportDestination) || shouldShowTaxError || shouldShowLocationError;
const {reimbursableExpensesAccount, reimbursableExpensesExportDestination, errorFields, pendingFields} = policy?.connections?.quickbooksOnline?.config ?? {};
const hasErrors = Boolean(errorFields?.reimbursableExpensesExportDestination);

return (
<AccessOrNotFoundWrapper
Expand All @@ -37,7 +33,7 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyConne
>
<HeaderWithBackButton title={translate('workspace.qbo.exportExpenses')} />
<ScrollView contentContainerStyle={styles.pb2}>
{!isLocationEnabled && <Text style={[styles.ph5, styles.pb5]}>{translate('workspace.qbo.exportOutOfPocketExpensesDescription')}</Text>}
<Text style={[styles.ph5, styles.pb5]}>{translate('workspace.qbo.exportOutOfPocketExpensesDescription')}</Text>
<OfflineWithFeedback pendingAction={pendingFields?.reimbursableExpensesExportDestination}>
<MenuItemWithTopDescription
title={reimbursableExpensesExportDestination ? translate(`workspace.qbo.accounts.${reimbursableExpensesExportDestination}`) : undefined}
Expand All @@ -47,24 +43,22 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyConne
brickRoadIndicator={hasErrors ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
shouldShowRightIcon
hintText={
reimbursableExpensesExportDestination === CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.VENDOR_BILL && !isLocationEnabled
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same ^

reimbursableExpensesExportDestination === CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.VENDOR_BILL
? translate('workspace.qbo.exportVendorBillDescription')
: undefined
}
/>
</OfflineWithFeedback>
{!isLocationEnabled && (
<OfflineWithFeedback pendingAction={pendingFields?.reimbursableExpensesAccount}>
<MenuItemWithTopDescription
Comment on lines -56 to -58
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This render condition was used so we don't show the account row if the selected entity value is invalid/unsupported (e.g. vendor bill with location enabled).

This is all outdated as the user won't fall into a case where the selected value is invalid.

title={reimbursableExpensesAccount?.name}
description={translate('workspace.qbo.accountsPayable')}
onPress={() => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT.getRoute(policyID))}
brickRoadIndicator={errorFields?.exportAccount ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
shouldShowRightIcon
errorText={errorFields?.exportAccount ? translate('common.genericErrorMessage') : undefined}
/>
</OfflineWithFeedback>
)}
<OfflineWithFeedback pendingAction={pendingFields?.reimbursableExpensesAccount}>
<MenuItemWithTopDescription
title={reimbursableExpensesAccount?.name}
description={translate('workspace.qbo.accountsPayable')}
onPress={() => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT.getRoute(policyID))}
brickRoadIndicator={errorFields?.exportAccount ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
shouldShowRightIcon
errorText={errorFields?.exportAccount ? translate('common.genericErrorMessage') : undefined}
/>
</OfflineWithFeedback>
</ScrollView>
</ScreenWrapper>
</AccessOrNotFoundWrapper>
Expand Down
Loading