Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions src/libs/actions/connections/QuickbooksOnline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ function updateQuickbooksOnlineCollectionAccountID<TSettingValue extends QBOConn
settingValue: TSettingValue,
oldSettingValue?: TSettingValue,
) {
if (settingValue === oldSettingValue) {
return;
}

const {optimisticData, failureData, successData} = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICKBOOKS_CONFIG.COLLECTION_ACCOUNT_ID, settingValue, oldSettingValue);

const parameters: UpdateQuickbooksOnlineGenericTypeParams = {
Expand All @@ -365,6 +369,9 @@ function updateQuickbooksOnlineReimbursementAccountID<TSettingValue extends Conn
settingValue: TSettingValue,
oldSettingValue?: TSettingValue,
) {
if (settingValue === oldSettingValue) {
return;
}
const onyxData = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICKBOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, settingValue, oldSettingValue);

const parameters: UpdateQuickbooksOnlineGenericTypeParams = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyConnectionsProps) {

const saveSelection = useCallback(
({value}: SelectorType) => {
if (value !== qboConfig?.reimbursementAccountID) {
QuickbooksOnline.updateQuickbooksOnlineReimbursementAccountID(policyID, value, qboConfig?.reimbursementAccountID);
}
QuickbooksOnline.updateQuickbooksOnlineReimbursementAccountID(policyID, value, qboConfig?.reimbursementAccountID);

@paultsimura paultsimura Nov 27, 2024 •

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.

I think this change is accidental. You probably wanted to revert the first commit, which is in src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx.

Otherwise, you should introduce the early return to the updateQuickbooksOnlineReimbursementAccountID function as well and keep this change. I would say it's worth doing.

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, you're right.

Let's do the same logic for QuickbooksAccountSelectPage.tsx though, and make the methods handle the possibility of setting the same value, to improve reusability.

Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ADVANCED.getRoute(policyID));
},
[policyID, qboConfig?.reimbursementAccountID],
Expand Down