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

Workspace Feed - Fix export item issues #52180

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 0 additions & 10 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,6 @@ const CONST = {
JOBS: 'jobs',
},
},
NETSUITE_CUSTOM_LIST_LIMIT: 8,
NETSUITE_ADD_CUSTOM_LIST_STEP_NAMES: ['1', '2,', '3', '4'],
NETSUITE_ADD_CUSTOM_SEGMENT_STEP_NAMES: ['1', '2,', '3', '4', '5', '6,'],
},
Expand Down Expand Up @@ -4545,9 +4544,6 @@ const CONST = {
},
INDENTS: ' ',
PARENT_CHILD_SEPARATOR: ': ',
CATEGORY_LIST_THRESHOLD: 8,
TAG_LIST_THRESHOLD: 8,
TAX_RATES_LIST_THRESHOLD: 8,
COLON: ':',
MAPBOX: {
PADDING: 32,
Expand Down Expand Up @@ -4631,11 +4627,6 @@ const CONST = {
*/
MAX_SELECTION_LIST_PAGE_LENGTH: 500,

/**
* We only include the members search bar when we have 8 or more members
*/
SHOULD_SHOW_MEMBERS_SEARCH_INPUT_BREAKPOINT: 8,

/**
* Bank account names
*/
Expand Down Expand Up @@ -4809,7 +4800,6 @@ const CONST = {
WORKSPACE_SWITCHER: {
NAME: 'Expensify',
SUBSCRIPT_ICON_SIZE: 8,
MINIMUM_WORKSPACES_TO_SHOW_SEARCH: 8,
},

WELCOME_VIDEO_URL: `${CLOUDFRONT_URL}/videos/intro-1280.mp4`,
Expand Down
2 changes: 1 addition & 1 deletion src/components/CategoryPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function CategoryPicker({selectedCategory, policyID, onSubmit}: CategoryPickerPr
const categoryData = categoryOptions?.at(0)?.data ?? [];
const header = OptionsListUtils.getHeaderMessageForNonUserList(categoryData.length > 0, debouncedSearchValue);
const categoriesCount = OptionsListUtils.getEnabledCategoriesCount(categories);
const isCategoriesCountBelowThreshold = categoriesCount < CONST.CATEGORY_LIST_THRESHOLD;
const isCategoriesCountBelowThreshold = categoriesCount < CONST.STANDARD_LIST_ITEM_LIMIT;
const showInput = !isCategoriesCountBelowThreshold;

return [categoryOptions, header, showInput];
Expand Down
2 changes: 1 addition & 1 deletion src/components/TagPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function TagPicker({selectedTag, tagListName, policyID, tagListIndex, shouldShow
const policyRecentlyUsedTagsList = useMemo(() => policyRecentlyUsedTags?.[tagListName] ?? [], [policyRecentlyUsedTags, tagListName]);
const policyTagList = PolicyUtils.getTagList(policyTags, tagListIndex);
const policyTagsCount = PolicyUtils.getCountOfEnabledTagsOfList(policyTagList.tags);
const isTagsCountBelowThreshold = policyTagsCount < CONST.TAG_LIST_THRESHOLD;
const isTagsCountBelowThreshold = policyTagsCount < CONST.STANDARD_LIST_ITEM_LIMIT;

const shouldShowTextInput = !isTagsCountBelowThreshold;

Expand Down
2 changes: 1 addition & 1 deletion src/components/TaxPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function TaxPicker({selectedTaxRate = '', policy, transaction, insets, onSubmit,

const taxRates = policy?.taxRates;
const taxRatesCount = TransactionUtils.getEnabledTaxRateCount(taxRates?.taxes ?? {});
const isTaxRatesCountBelowThreshold = taxRatesCount < CONST.TAX_RATES_LIST_THRESHOLD;
const isTaxRatesCountBelowThreshold = taxRatesCount < CONST.STANDARD_LIST_ITEM_LIMIT;

const shouldShowTextInput = !isTaxRatesCountBelowThreshold;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type SetCompanyCardExportAccountParams = {
authToken?: string | null;
cardID: number;
exportAccountDetails: Record<string, string>;
exportAccountDetails: string;
};

export default SetCompanyCardExportAccountParams;
6 changes: 3 additions & 3 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ function getCategoryListSections(
const selectedOptionNames = selectedOptions.map((selectedOption) => selectedOption.name);
const filteredCategories = enabledCategories.filter((category) => !selectedOptionNames.includes(category.name));

if (numberOfEnabledCategories < CONST.CATEGORY_LIST_THRESHOLD) {
if (numberOfEnabledCategories < CONST.STANDARD_LIST_ITEM_LIMIT) {
const data = getCategoryOptionTree(filteredCategories, false, selectedOptionsWithDisabledState);
categorySections.push({
// "All" section when items amount less than the threshold
Expand Down Expand Up @@ -1249,7 +1249,7 @@ function getTagListSections(
return tagSections;
}

if (numberOfTags < CONST.TAG_LIST_THRESHOLD) {
if (numberOfTags < CONST.STANDARD_LIST_ITEM_LIMIT) {
tagSections.push({
// "All" section when items amount less than the threshold
title: '',
Expand Down Expand Up @@ -1456,7 +1456,7 @@ function getTaxRatesSection(policy: OnyxEntry<Policy> | undefined, selectedOptio
return policyRatesSections;
}

if (numberOfTaxRates < CONST.TAX_RATES_LIST_THRESHOLD) {
if (numberOfTaxRates < CONST.STANDARD_LIST_ITEM_LIMIT) {
policyRatesSections.push({
// "All" section when items amount less than the threshold
title: '',
Expand Down
10 changes: 5 additions & 5 deletions src/libs/actions/CompanyCards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,13 @@ function updateCompanyCardName(workspaceAccountID: number, cardID: string, newCa
API.write(WRITE_COMMANDS.UPDATE_COMPANY_CARD_NAME, parameters, {optimisticData, finallyData, failureData});
}

function setCompanyCardExportAccount(workspaceAccountID: number, cardID: string, accountKey: string, newAccount: string, bankName: string) {
function setCompanyCardExportAccount(policyID: string, workspaceAccountID: number, cardID: string, accountKey: string, newAccount: string) {
const authToken = NetworkStore.getAuthToken();

const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`,
key: ONYXKEYS.CARD_LIST,
value: {
[cardID]: {
nameValuePairs: {
Expand All @@ -489,7 +489,7 @@ function setCompanyCardExportAccount(workspaceAccountID: number, cardID: string,
const finallyData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`,
key: ONYXKEYS.CARD_LIST,
value: {
[cardID]: {
nameValuePairs: {
Expand All @@ -504,7 +504,7 @@ function setCompanyCardExportAccount(workspaceAccountID: number, cardID: string,
const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bankName}`,
key: ONYXKEYS.CARD_LIST,
value: {
[cardID]: {
nameValuePairs: {
Expand All @@ -523,7 +523,7 @@ function setCompanyCardExportAccount(workspaceAccountID: number, cardID: string,
const parameters: SetCompanyCardExportAccountParams = {
authToken,
cardID: Number(cardID),
exportAccountDetails: {[accountKey]: newAccount},
exportAccountDetails: JSON.stringify({[accountKey]: newAccount, [`${accountKey}_policy_id`]: policyID}),
};

API.write(WRITE_COMMANDS.SET_CARD_EXPORT_ACCOUNT, parameters, {optimisticData, finallyData, failureData});
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ReportParticipantsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function ReportParticipantsPage({report, route}: ReportParticipantsPageProps) {
});

// Include the search bar when there are 8 or more active members in the selection list
const shouldShowTextInput = activeParticipants.length >= CONST.SHOULD_SHOW_MEMBERS_SEARCH_INPUT_BREAKPOINT;
const shouldShowTextInput = activeParticipants.length >= CONST.STANDARD_LIST_ITEM_LIMIT;

useEffect(() => {
if (!isFocused) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/RoomMembersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function RoomMembersPage({report, policies}: RoomMembersPageProps) {
// When offline, we want to include the pending members with delete action as they are displayed in the list as well
return !pendingMember || isOffline || pendingMember.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
});
return activeParticipants.length >= CONST.SHOULD_SHOW_MEMBERS_SEARCH_INPUT_BREAKPOINT;
return activeParticipants.length >= CONST.STANDARD_LIST_ITEM_LIMIT;
}, [participants, personalDetails, isOffline, report]);

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/WorkspaceSwitcherPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ function WorkspaceSwitcherPage() {
ListItem={UserListItem}
sections={sections}
onSelectRow={selectPolicy}
textInputLabel={usersWorkspaces.length >= CONST.WORKSPACE_SWITCHER.MINIMUM_WORKSPACES_TO_SHOW_SEARCH ? translate('common.search') : undefined}
textInputLabel={usersWorkspaces.length >= CONST.STANDARD_LIST_ITEM_LIMIT ? translate('common.search') : undefined}
textInputValue={searchTerm}
onChangeText={setSearchTerm}
headerMessage={headerMessage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function NetSuiteCustomListSelectorModal({isVisible, currentCustomListValue, onC
},
],
headerMessage: isEmpty ? translate('common.noResultsFound') : '',
showTextInput: customListData.length > CONST.NETSUITE_CONFIG.NETSUITE_CUSTOM_LIST_LIMIT,
showTextInput: customListData.length > CONST.STANDARD_LIST_ITEM_LIMIT,
};
}, [debouncedSearchValue, policy?.connections?.netsuite?.options?.data?.customLists, translate, currentCustomListValue]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function WorkspaceCompanyCardAccountSelectCardPage({route}: WorkspaceCompanyCard
const workspaceAccountID = PolicyUtils.getWorkspaceAccountID(policyID);
const [searchText, setSearchText] = useState('');

const [allBankCards] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${bank}`);
const [allBankCards] = useOnyx(`${ONYXKEYS.CARD_LIST}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

@narefyev91 Could you explain this change? I think using ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST is correct on this page. please correct me If I am wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DylanDylann on src/pages/workspace/companyCards/WorkspaceCompanyCardDetailsPage.tsx - we show information which is coming from here:
Screenshot 2024-11-08 at 10 54 03

That's why any changes using ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST was not shown on WorkspaceCompanyCardDetailsPage - because we are not using that key for showing card details

Copy link
Contributor

Choose a reason for hiding this comment

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

@narefyev91 Could you please merge main and check again? It has been updated recently

const card = allBankCards?.[cardID];
const connectedIntegration = PolicyUtils.getConnectedIntegration(policy) ?? CONST.POLICY.CONNECTIONS.NAME.QBO;
const exportMenuItem = getExportMenuItem(connectedIntegration, policyID, translate, policy, card);
Expand Down Expand Up @@ -63,7 +63,7 @@ function WorkspaceCompanyCardAccountSelectCardPage({route}: WorkspaceCompanyCard
if (!exportMenuItem?.exportType) {
return;
}
CompanyCards.setCompanyCardExportAccount(workspaceAccountID, cardID, exportMenuItem.exportType, value, bank);
CompanyCards.setCompanyCardExportAccount(policyID, workspaceAccountID, cardID, exportMenuItem.exportType, value);

Navigation.goBack(ROUTES.WORKSPACE_COMPANY_CARD_DETAILS.getRoute(policyID, cardID, bank));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function WorkspaceCompanyCardDetailsPage({route}: WorkspaceCompanyCardDetailsPag
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARD_NAME.getRoute(policyID, cardID, bank))}
/>
</OfflineWithFeedback>
{!!exportMenuItem && (
{exportMenuItem?.shouldShowMenuItem ? (
<OfflineWithFeedback
pendingAction={card?.nameValuePairs?.pendingFields?.exportAccountDetails}
errorRowStyles={[styles.ph5, styles.mb3]}
Expand All @@ -142,7 +142,7 @@ function WorkspaceCompanyCardDetailsPage({route}: WorkspaceCompanyCardDetailsPag
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARD_EXPORT.getRoute(policyID, cardID, bank))}
/>
</OfflineWithFeedback>
)}
) : null}
<MenuItemWithTopDescription
shouldShowRightComponent={card?.isLoadingLastUpdated}
rightComponent={
Expand Down
32 changes: 23 additions & 9 deletions src/pages/workspace/companyCards/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type ExportIntegration = {
onExportPagePress: () => void;
data: SelectorType[];
exportType?: string;
shouldShowMenuItem?: boolean;
};

function getExportMenuItem(
Expand All @@ -32,38 +33,42 @@ function getExportMenuItem(
): ExportIntegration | undefined {
const currentConnectionName = PolicyUtils.getCurrentConnectionName(policy);

const {nonReimbursableExpensesExportDestination} = policy?.connections?.quickbooksOnline?.config ?? {};
const {nonReimbursableExpensesExportDestination, nonReimbursableExpensesAccount} = policy?.connections?.quickbooksOnline?.config ?? {};
const {export: exportConfig} = policy?.connections?.intacct?.config ?? {};
const {export: exportConfiguration} = policy?.connections?.xero?.config ?? {};
const config = policy?.connections?.netsuite?.options.config;
const {bankAccounts} = policy?.connections?.xero?.data ?? {};
const {creditCards, bankAccounts: quickbooksOnlineBankAccounts} = policy?.connections?.quickbooksOnline?.data ?? {};

switch (connectionName) {
case CONST.POLICY.CONNECTIONS.NAME.QBO: {
const type = nonReimbursableExpensesExportDestination ? translate(`workspace.qbo.accounts.${nonReimbursableExpensesExportDestination}`) : undefined;
const description = currentConnectionName && type ? translate('workspace.moreFeatures.companyCards.integrationExport', {integration: currentConnectionName, type}) : undefined;
let data: Account[];
let shouldShowMenuItem = true;
let title: string | undefined = '';
let exportType: string | undefined = '';
switch (nonReimbursableExpensesExportDestination) {
case CONST.QUICKBOOKS_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE.CREDIT_CARD:
data = creditCards ?? [];
title = companyCard?.nameValuePairs?.exportAccountDetails?.quickbooks_desktop_export_account_credit;
title = companyCard?.nameValuePairs?.exportAccountDetails?.quickbooks_desktop_export_account_credit ?? nonReimbursableExpensesAccount?.name;
exportType = CONST.COMPANY_CARDS.EXPORT_CARD_TYPES.NVP_QUICKBOOKS_DESKTOP_EXPORT_ACCOUNT_CREDIT;
break;
case CONST.QUICKBOOKS_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE.DEBIT_CARD:
data = quickbooksOnlineBankAccounts ?? [];
title = companyCard?.nameValuePairs?.exportAccountDetails?.quickbooks_online_export_account_debit;
title = companyCard?.nameValuePairs?.exportAccountDetails?.quickbooks_online_export_account_debit ?? nonReimbursableExpensesAccount?.name;
exportType = CONST.COMPANY_CARDS.EXPORT_CARD_TYPES.NVP_QUICKBOOKS_ONLINE_EXPORT_ACCOUNT_DEBIT;
break;
default:
shouldShowMenuItem = false;
data = [];
}

return {
description,
title,
exportType,
shouldShowMenuItem,
onExportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT.getRoute(policyID)),
data: data.map((card) => ({
value: card.name,
Expand All @@ -77,10 +82,12 @@ function getExportMenuItem(
const type = translate('workspace.xero.xeroBankAccount');
const description = currentConnectionName && type ? translate('workspace.moreFeatures.companyCards.integrationExport', {integration: currentConnectionName, type}) : undefined;
const exportType = CONST.COMPANY_CARDS.EXPORT_CARD_TYPES.NVP_XERO_EXPORT_BANK_ACCOUNT;
const selectedAccount = (bankAccounts ?? []).find((bank) => bank.id === exportConfiguration?.nonReimbursableAccount);
return {
description,
exportType,
title: companyCard?.nameValuePairs?.exportAccountDetails?.xero_export_bank_account,
shouldShowMenuItem: true,
title: companyCard?.nameValuePairs?.exportAccountDetails?.xero_export_bank_account ?? selectedAccount?.name ?? bankAccounts?.[0]?.name ?? '',
onExportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_EXPORT.getRoute(policyID)),
data: getXeroBankAccounts(policy ?? undefined, exportConfiguration?.nonReimbursableAccount),
};
Expand All @@ -91,26 +98,28 @@ function getExportMenuItem(
: undefined;
let title: string | undefined = '';
let exportType: string | undefined = '';
let shouldShowMenuItem = true;
const description = currentConnectionName && type ? translate('workspace.moreFeatures.companyCards.integrationExport', {integration: currentConnectionName, type}) : undefined;
let data: SelectorType[];
switch (config?.nonreimbursableExpensesExportDestination) {
case CONST.NETSUITE_EXPORT_DESTINATION.VENDOR_BILL:
title = companyCard?.nameValuePairs?.exportAccountDetails?.netsuite_export_vendor;
data = getNetSuiteVendorOptions(policy ?? undefined, config?.defaultVendor);
title = companyCard?.nameValuePairs?.exportAccountDetails?.netsuite_export_vendor ?? data.find((exportVendor) => exportVendor.isSelected)?.text;
exportType = CONST.COMPANY_CARDS.EXPORT_CARD_TYPES.NVP_NETSUITE_EXPORT_VENDOR;
break;
case CONST.NETSUITE_EXPORT_DESTINATION.JOURNAL_ENTRY:
title = companyCard?.nameValuePairs?.exportAccountDetails?.netsuite_export_payable_account;
data = getNetSuitePayableAccountOptions(policy ?? undefined, config?.payableAcct);
title = companyCard?.nameValuePairs?.exportAccountDetails?.netsuite_export_payable_account ?? data.find((exportPayable) => exportPayable.isSelected)?.text;
exportType = CONST.COMPANY_CARDS.EXPORT_CARD_TYPES.NVP_NETSUITE_EXPORT_ACCOUNT;

break;
default:
shouldShowMenuItem = false;
data = [];
}
return {
description,
title,
shouldShowMenuItem,
exportType,
data,
onExportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_EXPORT.getRoute(policyID)),
Expand All @@ -121,13 +130,18 @@ function getExportMenuItem(
const type = exportConfig?.nonReimbursable ? translate(`workspace.sageIntacct.nonReimbursableExpenses.values.${exportConfig.nonReimbursable}`) : undefined;
const description = currentConnectionName && type ? translate('workspace.moreFeatures.companyCards.integrationExport', {integration: currentConnectionName, type}) : undefined;
const activeDefaultVendor = getSageIntacctNonReimbursableActiveDefaultVendor(policy);
const data = isVendor ? getSageIntacctVendors(policy, activeDefaultVendor) : getSageIntacctCreditCards(policy, exportConfig?.nonReimbursableAccount);
const selectedAccount = data.find((account) => account.isSelected)?.text;

return {
description,
shouldShowMenuItem: true,
exportType: isVendor ? CONST.COMPANY_CARDS.EXPORT_CARD_TYPES.NVP_INTACCT_EXPORT_VENDOR : CONST.COMPANY_CARDS.EXPORT_CARD_TYPES.NVP_INTACCT_EXPORT_CHARGE_CARD,
title: isVendor ? companyCard?.nameValuePairs?.exportAccountDetails?.intacct_export_vendor : companyCard?.nameValuePairs?.exportAccountDetails?.intacct_export_charge_card,
title: isVendor
? companyCard?.nameValuePairs?.exportAccountDetails?.intacct_export_vendor ?? selectedAccount
: companyCard?.nameValuePairs?.exportAccountDetails?.intacct_export_charge_card ?? selectedAccount,
onExportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID)),
data: isVendor ? getSageIntacctVendors(policy, activeDefaultVendor) : getSageIntacctCreditCards(policy, exportConfig?.nonReimbursableAccount),
data,
};
}
default:
Expand Down
Loading
Loading