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

Don't apply failure data for 460 jsonCode #49759

Merged
merged 2 commits into from
Sep 27, 2024
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
8 changes: 8 additions & 0 deletions src/libs/actions/OnyxUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ function applyHTTPSOnyxUpdates(request: Request, response: Response) {
return updateHandler(request.successData);
}
if (response.jsonCode !== 200 && request.failureData) {
// 460 jsonCode in Expensify world means "admin required".
// Typically, this would only happen if a user attempts an API command that requires policy admin access when they aren't an admin.
// In this case, we don't want to apply failureData because it will likely result in a RedBrickRoad error on a policy field which is not accessible.
// Meaning that there's a red dot you can't dismiss.
if (response.jsonCode === 460) {
Log.info('[OnyxUpdateManager] Received 460 status code, not applying failure data');
return Promise.resolve();
}
return updateHandler(request.failureData);
}
return Promise.resolve();
Expand Down
6 changes: 1 addition & 5 deletions src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,10 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) {
}, [policy, route.params.policyID, availableMembers, usedApproverEmails]);

const optionItems: ToggleSettingOptionRowProps[] = useMemo(() => {
const {accountNumber, addressName, bankName, bankAccountID} = policy?.achAccount ?? {};
const {addressName, bankName, bankAccountID} = policy?.achAccount ?? {};
const shouldShowBankAccount = !!bankAccountID && policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES;
const bankIcon = getBankIcon({bankName: bankName as BankName, isCard: false, styles});

let bankDisplayName = bankName ?? addressName;
if (accountNumber && bankDisplayName !== accountNumber) {
bankDisplayName += ` ${accountNumber.slice(-5)}`;
}
Comment on lines -116 to -119
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this change for?

Copy link
Contributor

Choose a reason for hiding this comment

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

bankDisplayName is unused variable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, sorry just doing some scope-creep cleanup of unused code

const hasReimburserError = !!policy?.errorFields?.reimburser;
const hasApprovalError = !!policy?.errorFields?.approvalMode;
const hasDelayedSubmissionError = !!policy?.errorFields?.autoReporting ?? !!policy?.errorFields?.autoReportingFrequency;
Expand Down
Loading