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
18 changes: 17 additions & 1 deletion src/components/TestToolMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import React from 'react';
import useIsAuthenticated from '@hooks/useIsAuthenticated';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
import useThemeStyles from '@hooks/useThemeStyles';
import {isUsingStagingApi} from '@libs/ApiUtils';
import {setShouldFailAllRequests, setShouldForceOffline, setShouldSimulatePoorConnection} from '@userActions/Network';
import {expireSessionWithDelay, invalidateAuthToken, invalidateCredentials} from '@userActions/Session';
import {setIsDebugModeEnabled, setShouldUseStagingServer} from '@userActions/User';
import {setIsDebugModeEnabled, setShouldBlockTransactionThreadReportCreation, setShouldUseStagingServer} from '@userActions/User';
import CONFIG from '@src/CONFIG';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Account as AccountOnyx} from '@src/types/onyx';
import Button from './Button';
Expand All @@ -27,11 +29,14 @@ const ACCOUNT_DEFAULT: AccountOnyx = {
};

function TestToolMenu() {
const {isBetaEnabled} = usePermissions();
const [network] = useOnyx(ONYXKEYS.NETWORK, {canBeMissing: true});
const [account = ACCOUNT_DEFAULT] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
const [isUsingImportedState] = useOnyx(ONYXKEYS.IS_USING_IMPORTED_STATE, {canBeMissing: true});
const shouldUseStagingServer = account?.shouldUseStagingServer ?? isUsingStagingApi();
const isDebugModeEnabled = !!account?.isDebugModeEnabled;
const shouldBlockTransactionThreadReportCreation = !!account?.shouldBlockTransactionThreadReportCreation;
const shouldShowTransactionThreadReportToggle = isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS);
const styles = useThemeStyles();
const {translate} = useLocalize();

Expand All @@ -48,6 +53,17 @@ function TestToolMenu() {
</Text>
{isAuthenticated && (
<>
{/* When toggled, the app won't create the transaction thread report. It should be removed together with CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS beta */}
{shouldShowTransactionThreadReportToggle && (
<TestToolRow title={translate('initialSettingsPage.troubleshoot.shouldBlockTransactionThreadReportCreation')}>
<Switch
accessibilityLabel={translate('initialSettingsPage.troubleshoot.shouldBlockTransactionThreadReportCreation')}
isOn={shouldBlockTransactionThreadReportCreation}
onToggle={() => setShouldBlockTransactionThreadReportCreation(!shouldBlockTransactionThreadReportCreation)}
/>
</TestToolRow>
)}

{/* When toggled the app will be put into debug mode. */}
<TestToolRow title={translate('initialSettingsPage.troubleshoot.debugMode')}>
<Switch
Expand Down
1 change: 1 addition & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,7 @@ const translations = {
testCrash: 'Testabsturz',
resetToOriginalState: 'Auf den ursprünglichen Zustand zurücksetzen',
usingImportedState: 'Sie verwenden importierten Status. Drücken Sie hier, um ihn zu löschen.',
shouldBlockTransactionThreadReportCreation: 'Erstellung von Transaktions-Thread-Berichten blockieren',
debugMode: 'Debug-Modus',
invalidFile: 'Ungültige Datei',
invalidFileDescription: 'Die Datei, die Sie importieren möchten, ist ungültig. Bitte versuchen Sie es erneut.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,7 @@ const translations = {
testCrash: 'Test crash',
resetToOriginalState: 'Reset to original state',
usingImportedState: 'You are using imported state. Press here to clear it.',
shouldBlockTransactionThreadReportCreation: 'Block transaction thread report creation',
debugMode: 'Debug mode',
invalidFile: 'Invalid file',
invalidFileDescription: 'The file you are trying to import is not valid. Please try again.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,7 @@ const translations = {
testCrash: 'Prueba de fallo',
resetToOriginalState: 'Restablecer al estado original',
usingImportedState: 'Estás utilizando el estado importado. Pulsa aquí para borrarlo.',
shouldBlockTransactionThreadReportCreation: 'Bloquear la creación de informes de hilos de transacciones',
debugMode: 'Modo depuración',
invalidFile: 'Archivo inválido',
invalidFileDescription: 'El archivo que ests intentando importar no es válido. Por favor, inténtalo de nuevo.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,7 @@ const translations = {
testCrash: 'Test crash',
resetToOriginalState: "Réinitialiser à l'état d'origine",
usingImportedState: 'Vous utilisez un état importé. Appuyez ici pour le réinitialiser.',
shouldBlockTransactionThreadReportCreation: 'Bloquer la création de rapports de fil de transaction',
debugMode: 'Mode débogage',
invalidFile: 'Fichier invalide',
invalidFileDescription: "Le fichier que vous essayez d'importer n'est pas valide. Veuillez réessayer.",
Expand Down
1 change: 1 addition & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,7 @@ const translations = {
testCrash: 'Test crash',
resetToOriginalState: 'Ripristina allo stato originale',
usingImportedState: 'Stai utilizzando uno stato importato. Premi qui per cancellarlo.',
shouldBlockTransactionThreadReportCreation: 'Blocca la creazione di report del thread di transazione',
debugMode: 'Modalità debug',
invalidFile: 'File non valido',
invalidFileDescription: 'Il file che stai cercando di importare non è valido. Per favore riprova.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,7 @@ const translations = {
testCrash: 'クラッシュのテスト',
resetToOriginalState: '元の状態にリセット',
usingImportedState: 'インポートされた状態を使用しています。ここを押してクリアしてください。',
shouldBlockTransactionThreadReportCreation: 'トランザクションスレッドレポートの作成をブロック',
debugMode: 'デバッグモード',
invalidFile: '無効なファイル',
invalidFileDescription: 'インポートしようとしているファイルは無効です。もう一度お試しください。',
Expand Down
1 change: 1 addition & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,7 @@ const translations = {
testCrash: 'Test crash',
resetToOriginalState: 'Reset naar oorspronkelijke staat',
usingImportedState: 'U gebruikt geïmporteerde status. Druk hier om het te wissen.',
shouldBlockTransactionThreadReportCreation: 'Creatie van transactie thread rapporten blokkeren',
debugMode: 'Debug-modus',
invalidFile: 'Ongeldig bestand',
invalidFileDescription: 'Het bestand dat je probeert te importeren is niet geldig. Probeer het opnieuw.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,7 @@ const translations = {
testCrash: 'Test awarii',
resetToOriginalState: 'Przywróć do stanu początkowego',
usingImportedState: 'Używasz zaimportowanego stanu. Naciśnij tutaj, aby go wyczyścić.',
shouldBlockTransactionThreadReportCreation: 'Blokuj tworzenie raportów wątku transakcji',
debugMode: 'Tryb debugowania',
invalidFile: 'Nieprawidłowy plik',
invalidFileDescription: 'Plik, który próbujesz zaimportować, jest nieprawidłowy. Spróbuj ponownie.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,7 @@ const translations = {
testCrash: 'Teste de falha',
resetToOriginalState: 'Redefinir para o estado original',
usingImportedState: 'Você está usando um estado importado. Clique aqui para limpá-lo.',
shouldBlockTransactionThreadReportCreation: 'Bloquear a criação de relatórios de thread de transação',
debugMode: 'Modo de depuração',
invalidFile: 'Arquivo inválido',
invalidFileDescription: 'O arquivo que você está tentando importar não é válido. Por favor, tente novamente.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,7 @@ const translations = {
testCrash: '测试崩溃',
resetToOriginalState: '重置为原始状态',
usingImportedState: '您正在使用导入的状态。点击这里清除它。',
shouldBlockTransactionThreadReportCreation: '阻止创建交易线程报告',
debugMode: '调试模式',
invalidFile: '文件无效',
invalidFileDescription: '您尝试导入的文件无效。请再试一次。',
Expand Down
5 changes: 5 additions & 0 deletions src/libs/actions/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

let currentUserAccountID = -1;
let currentEmail = '';
Onyx.connect({

Check warning on line 65 in src/libs/actions/User.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
currentUserAccountID = value?.accountID ?? CONST.DEFAULT_NUMBER_ID;
Expand All @@ -71,7 +71,7 @@
});

let myPersonalDetails: OnyxEntry<OnyxPersonalDetails>;
Onyx.connect({

Check warning on line 74 in src/libs/actions/User.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
if (!value || currentUserAccountID === -1) {
Expand All @@ -83,7 +83,7 @@
});

let allPolicies: OnyxCollection<Policy>;
Onyx.connect({

Check warning on line 86 in src/libs/actions/User.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => (allPolicies = value),
Expand Down Expand Up @@ -669,7 +669,7 @@

const isChannelMuted = (reportId: string) =>
new Promise((resolve) => {
const connection = Onyx.connect({

Check warning on line 672 in src/libs/actions/User.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: `${ONYXKEYS.COLLECTION.REPORT}${reportId}`,
callback: (report) => {
Onyx.disconnect(connection);
Expand Down Expand Up @@ -1393,6 +1393,10 @@
Onyx.merge(ONYXKEYS.ACCOUNT, {isDebugModeEnabled});
}

function setShouldBlockTransactionThreadReportCreation(shouldBlockTransactionThreadReportCreation: boolean) {
Onyx.merge(ONYXKEYS.ACCOUNT, {shouldBlockTransactionThreadReportCreation});
}
Comment on lines +1396 to +1398

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.

Is it not possible to change the value of the beta itself in Onyx instead of adding a new value in account? I think it would make this check less confusing:

    const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS) || !account?.shouldBlockTransactionThreadReportCreation;

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.

It's possible, but:

  • if QA needs to Clear cache and restart during the test flow - the betas will be reset, while the account data is preserved
  • Right now, we show the toggle only if beta is on. If we want to modify the betas instead of the account flag, then we will need to always show the toggle to all of the users

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.

ahh, I didn't know they would be reset, then I think what you have is better.


function lockAccount() {
const optimisticData: OnyxUpdate[] = [
{
Expand Down Expand Up @@ -1476,6 +1480,7 @@
addPendingContactMethod,
clearValidateCodeActionError,
setIsDebugModeEnabled,
setShouldBlockTransactionThreadReportCreation,
resetValidateActionCodeSent,
lockAccount,
};
3 changes: 2 additions & 1 deletion src/pages/Share/SubmitDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function SubmitDetailsPage({
const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${getIOURequestPolicyID(transaction, report)}`, {canBeMissing: false});
const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${getIOURequestPolicyID(transaction, report)}`, {canBeMissing: false});
const [lastLocationPermissionPrompt] = useOnyx(ONYXKEYS.NVP_LAST_LOCATION_PERMISSION_PROMPT, {canBeMissing: false});
const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports});
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const [startLocationPermissionFlow, setStartLocationPermissionFlow] = useState(false);
Expand All @@ -58,7 +59,7 @@ function SubmitDetailsPage({
const [errorMessage, setErrorMessage] = useState<string | undefined>(undefined);

const {isBetaEnabled} = usePermissions();
const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS);
const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS) || !account?.shouldBlockTransactionThreadReportCreation;

useEffect(() => {
if (!errorTitle || !errorMessage) {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/iou/request/step/IOURequestStepAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function IOURequestStepAmount({
const [skipConfirmation] = useOnyx(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`, {canBeMissing: true});
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});
const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`, {canBeMissing: true});
const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
const {duplicateTransactions, duplicateTransactionViolations} = useDuplicateTransactionsAndViolations(transactionID ? [transactionID] : []);
const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports});
const isEditing = action === CONST.IOU.ACTION.EDIT;
Expand All @@ -97,7 +98,7 @@ function IOURequestStepAmount({
const currency = isValidCurrencyCode(selectedCurrency) ? selectedCurrency : originalCurrency;
// eslint-disable-next-line rulesdir/no-negated-variables
const shouldShowNotFoundPage = useShowNotFoundPageInIOUStep(action, iouType, reportActionID, report, transaction);
const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS);
const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS) || !account?.shouldBlockTransactionThreadReportCreation;

// For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace request, as
// the user will have to add a merchant.
Expand Down
3 changes: 2 additions & 1 deletion src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ function IOURequestStepConfirmation({
const [userLocation] = useOnyx(ONYXKEYS.USER_LOCATION, {canBeMissing: true});
const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports});
const [recentlyUsedDestinations] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_DESTINATIONS}${realPolicyID}`, {canBeMissing: true});
const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});

/*
* We want to use a report from the transaction if it exists
Expand Down Expand Up @@ -218,7 +219,7 @@ function IOURequestStepConfirmation({
[transaction?.participants, iouType, personalDetails, reportAttributesDerived],
);
const isPolicyExpenseChat = useMemo(() => participants?.some((participant) => participant.isPolicyExpenseChat), [participants]);
const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS);
const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS) || !account?.shouldBlockTransactionThreadReportCreation;
const formHasBeenSubmitted = useRef(false);

useFetchRoute(transaction, transaction?.comment?.waypoints, action, shouldUseTransactionDraft(action) ? CONST.TRANSACTION.STATE.DRAFT : CONST.TRANSACTION.STATE.CURRENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function IOURequestStepScan({
const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`, {canBeMissing: true});
const [dismissedProductTraining] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {canBeMissing: true});
const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports});
const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
const platform = getPlatform(true);
const [mutedPlatforms = getEmptyObject<Partial<Record<Platform, true>>>()] = useOnyx(ONYXKEYS.NVP_MUTED_PLATFORMS, {canBeMissing: true});
const isPlatformMuted = mutedPlatforms[platform];
Expand All @@ -121,7 +122,7 @@ function IOURequestStepScan({
const [shouldShowMultiScanEducationalPopup, setShouldShowMultiScanEducationalPopup] = useState(false);
const [cameraKey, setCameraKey] = useState(0);
const {shouldStartLocationPermissionFlow} = useIOUUtils();
const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS);
const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS) || !account?.shouldBlockTransactionThreadReportCreation;

const defaultTaxCode = getDefaultTaxCode(policy, initialTransaction);
const transactionTaxCode = (initialTransaction?.taxCode ? initialTransaction?.taxCode : defaultTaxCode) ?? '';
Expand Down
3 changes: 2 additions & 1 deletion src/pages/iou/request/step/IOURequestStepScan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function IOURequestStepScan({
const getScreenshotTimeoutRef = useRef<NodeJS.Timeout | null>(null);
const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`, {canBeMissing: true});
const policy = usePolicy(report?.policyID);
const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {canBeMissing: false});
const [skipConfirmation] = useOnyx(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${initialTransactionID}`, {canBeMissing: true});
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: false});
Expand All @@ -123,7 +124,7 @@ function IOURequestStepScan({
const canUseMultiScan = !isEditing && iouType !== CONST.IOU.TYPE.SPLIT && !backTo && !backToReport;
const isReplacingReceipt = (isEditing && hasReceipt(initialTransaction)) || (!!initialTransaction?.receipt && !!backTo);
const {shouldStartLocationPermissionFlow} = useIOUUtils();
const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS);
const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS) || !account?.shouldBlockTransactionThreadReportCreation;

const [optimisticTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {
selector: (items) => Object.values(items ?? {}),
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ type Account = {
/** Whether we should use the staging version of the secure API server */
shouldUseStagingServer?: boolean;

/** Whether we should block the transaction thread report creation */
shouldBlockTransactionThreadReportCreation?: boolean;

/** Whether or not the user is on a public domain email account or not */
isFromPublicDomain?: boolean;

Expand Down
Loading