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

[Debug Mode] Add transaction and violation data to debug mode #50745

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
371c92a
feat(debug mode): add debug transaction page
pac-guerreiro Oct 14, 2024
09effbe
chore: create validateTransactionDraftProperty
pac-guerreiro Oct 15, 2024
415604c
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Oct 16, 2024
6922c05
chore(debug mode): finish DebugUtils.validateTransactionDraftData and…
pac-guerreiro Oct 16, 2024
86279f4
chore(debug mode): add debug transaction types
pac-guerreiro Oct 17, 2024
fd20c7b
feat(debug mode): add links for transaction and report
pac-guerreiro Oct 17, 2024
9db0e98
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Oct 17, 2024
d3af97f
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Oct 19, 2024
3202cd7
chore(debug mode): add transaction violation creation page
pac-guerreiro Oct 19, 2024
61c342a
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Oct 21, 2024
bc74450
chore(debug mode): add debug transaction violation page and finish de…
pac-guerreiro Oct 21, 2024
8ea1478
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Oct 21, 2024
8c6128b
chore(debug mode): add debug transaction violation draft form types
pac-guerreiro Oct 21, 2024
6af473b
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Oct 22, 2024
3f4dd04
chore(debug mode): fix mutating Onyx data causing set to fail and add…
pac-guerreiro Oct 23, 2024
4ac02f5
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Oct 23, 2024
bd4b641
refactor(debug mode): debug details constant fields
pac-guerreiro Oct 23, 2024
9d6b1ba
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Oct 23, 2024
754c5fa
refactor: make code more readable
pac-guerreiro Oct 24, 2024
41e12a3
fix: virtualized list error
pac-guerreiro Oct 24, 2024
4e50adb
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Oct 24, 2024
390a6a6
refactor: apply suggestions
pac-guerreiro Oct 24, 2024
cb91f47
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Oct 24, 2024
36e41ed
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Oct 25, 2024
38ea910
fix: jest unit tests failing
pac-guerreiro Oct 25, 2024
e1baf7b
chore: add missing test cases for debug utils
pac-guerreiro Oct 28, 2024
ca8dac6
fix(debug mode): view transaction now showing for some expense chats
pac-guerreiro Oct 28, 2024
00deac6
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Oct 28, 2024
4621e93
refactor: apply suggestions
pac-guerreiro Oct 29, 2024
f8933fe
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Oct 29, 2024
72630c6
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Oct 30, 2024
30c8004
refactor(debug mode): apply suggestions
pac-guerreiro Oct 31, 2024
03539f0
refactor: replace union with value of constant
pac-guerreiro Oct 31, 2024
f9477b4
refactor(debug mode): enforce property validation based on onyx data …
pac-guerreiro Oct 31, 2024
359041b
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Oct 31, 2024
31aec40
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Oct 31, 2024
8b557ef
chore: resolve eslint and jest issues
pac-guerreiro Oct 31, 2024
c0c97ae
fix: add missing property to transaction violation data type
pac-guerreiro Oct 31, 2024
fad107e
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Oct 31, 2024
18e0eeb
chore: resolve eslint issues
pac-guerreiro Oct 31, 2024
2ddd92e
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Nov 4, 2024
d4ac57a
feat(debug mode): add ability to select category and tag from a picker
pac-guerreiro Nov 4, 2024
54da244
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Nov 4, 2024
9100196
feat(debug mode): add ability to pick multi-level transaction tags
pac-guerreiro Nov 5, 2024
1b60f46
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Nov 5, 2024
1f75b91
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Nov 6, 2024
ba7f513
fix(debug mode): currency selector has lesser options than expected
pac-guerreiro Nov 6, 2024
66d7640
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Nov 7, 2024
beeccd2
fix: type definitions for arrays and objects used in validations
pac-guerreiro Nov 7, 2024
5214751
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Nov 7, 2024
ea21516
fix: missing array validation for previousMessage
pac-guerreiro Nov 7, 2024
984cabf
fix: remaining type definition issue
pac-guerreiro Nov 8, 2024
ae89328
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Nov 8, 2024
ff0aa9b
fix: linter issues
pac-guerreiro Nov 8, 2024
25d82ad
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Nov 12, 2024
bfca376
refactor: apply suggestions
pac-guerreiro Nov 12, 2024
504554c
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Nov 12, 2024
c38a7ad
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Nov 14, 2024
1a13849
chore: apply linter
pac-guerreiro Nov 14, 2024
7f589e5
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Nov 14, 2024
5d60250
chore: remove unused properties
pac-guerreiro Nov 14, 2024
180dbae
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Nov 14, 2024
aa53915
refactor: remove unused properties
pac-guerreiro Nov 14, 2024
8f35158
chore: remove unused properties
pac-guerreiro Nov 14, 2024
8bc86fe
chore: revert deletion of report property
pac-guerreiro Nov 14, 2024
2898d69
chore: apply suggestions
pac-guerreiro Nov 14, 2024
bf28176
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Nov 18, 2024
0be46ce
fix: merge conflicts
pac-guerreiro Nov 18, 2024
05c55c2
fix: eslint issues
pac-guerreiro Nov 18, 2024
6bfa9a9
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Nov 18, 2024
7a22246
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Nov 19, 2024
57e1023
fix(debug mode): problem updating nested objects in onyx
pac-guerreiro Nov 19, 2024
2e3a921
Merge branch 'main' into pac-guerreiro/feature/50335-add-transaction-…
pac-guerreiro Nov 21, 2024
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/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6299,10 +6299,17 @@ const CONST = {
},

DEBUG: {
FORMS: {
REPORT: 'report',
REPORT_ACTION: 'reportAction',
TRANSACTION: 'transaction',
TRANSACTION_VIOLATION: 'transactionViolation',
},
DETAILS: 'details',
JSON: 'json',
REPORT_ACTIONS: 'actions',
REPORT_ACTION_PREVIEW: 'preview',
TRANSACTION_VIOLATIONS: 'violations',
},

REPORT_IN_LHN_REASONS: {
Expand Down
8 changes: 1 addition & 7 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -716,10 +716,6 @@ const ONYXKEYS = {
RULES_MAX_EXPENSE_AMOUNT_FORM_DRAFT: 'rulesMaxExpenseAmountFormDraft',
RULES_MAX_EXPENSE_AGE_FORM: 'rulesMaxExpenseAgeForm',
RULES_MAX_EXPENSE_AGE_FORM_DRAFT: 'rulesMaxExpenseAgeFormDraft',
DEBUG_REPORT_PAGE_FORM: 'debugReportPageForm',
DEBUG_REPORT_PAGE_FORM_DRAFT: 'debugReportPageFormDraft',
DEBUG_REPORT_ACTION_PAGE_FORM: 'debugReportActionPageForm',
DEBUG_REPORT_ACTION_PAGE_FORM_DRAFT: 'debugReportActionPageFormDraft',
DEBUG_DETAILS_FORM: 'debugDetailsForm',
DEBUG_DETAILS_FORM_DRAFT: 'debugDetailsFormDraft',
},
Expand Down Expand Up @@ -814,9 +810,7 @@ type OnyxFormValuesMapping = {
[ONYXKEYS.FORMS.RULES_MAX_EXPENSE_AMOUNT_FORM]: FormTypes.RulesMaxExpenseAmountForm;
[ONYXKEYS.FORMS.RULES_MAX_EXPENSE_AGE_FORM]: FormTypes.RulesMaxExpenseAgeForm;
[ONYXKEYS.FORMS.SEARCH_SAVED_SEARCH_RENAME_FORM]: FormTypes.SearchSavedSearchRenameForm;
[ONYXKEYS.FORMS.DEBUG_REPORT_PAGE_FORM]: FormTypes.DebugReportForm;
[ONYXKEYS.FORMS.DEBUG_REPORT_ACTION_PAGE_FORM]: FormTypes.DebugReportActionForm;
[ONYXKEYS.FORMS.DEBUG_DETAILS_FORM]: FormTypes.DebugReportForm | FormTypes.DebugReportActionForm;
[ONYXKEYS.FORMS.DEBUG_DETAILS_FORM]: FormTypes.DebugReportForm | FormTypes.DebugReportActionForm | FormTypes.DebugTransactionForm | FormTypes.DebugTransactionViolationForm;
};

type OnyxFormDraftValuesMapping = {
Expand Down
37 changes: 35 additions & 2 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1777,13 +1777,46 @@ const ROUTES = {
getRoute: (reportID: string, reportActionID: string) => `debug/report/${reportID}/actions/${reportActionID}/preview` as const,
},
DETAILS_CONSTANT_PICKER_PAGE: {
route: 'debug/details/constant/:fieldName',
getRoute: (fieldName: string, fieldValue?: string, backTo?: string) => getUrlWithBackToParam(`debug/details/constant/${fieldName}?fieldValue=${fieldValue}`, backTo),
route: 'debug/:formType/details/constant/:fieldName',
getRoute: (formType: string, fieldName: string, fieldValue?: string, policyID?: string, backTo?: string) =>
getUrlWithBackToParam(`debug/${formType}/details/constant/${fieldName}?fieldValue=${fieldValue}&policyID=${policyID}`, backTo),
},
DETAILS_DATE_TIME_PICKER_PAGE: {
route: 'debug/details/datetime/:fieldName',
getRoute: (fieldName: string, fieldValue?: string, backTo?: string) => getUrlWithBackToParam(`debug/details/datetime/${fieldName}?fieldValue=${fieldValue}`, backTo),
},
DEBUG_TRANSACTION: {
route: 'debug/transaction/:transactionID',
getRoute: (transactionID: string) => `debug/transaction/${transactionID}` as const,
},
DEBUG_TRANSACTION_TAB_DETAILS: {
route: 'debug/transaction/:transactionID/details',
getRoute: (transactionID: string) => `debug/transaction/${transactionID}/details` as const,
},
DEBUG_TRANSACTION_TAB_JSON: {
route: 'debug/transaction/:transactionID/json',
getRoute: (transactionID: string) => `debug/transaction/${transactionID}/json` as const,
},
DEBUG_TRANSACTION_TAB_VIOLATIONS: {
route: 'debug/transaction/:transactionID/violations',
getRoute: (transactionID: string) => `debug/transaction/${transactionID}/violations` as const,
},
DEBUG_TRANSACTION_VIOLATION_CREATE: {
route: 'debug/transaction/:transactionID/violations/create',
getRoute: (transactionID: string) => `debug/transaction/${transactionID}/violations/create` as const,
},
DEBUG_TRANSACTION_VIOLATION: {
route: 'debug/transaction/:transactionID/violations/:index',
getRoute: (transactionID: string, index: string) => `debug/transaction/${transactionID}/violations/${index}` as const,
},
DEBUG_TRANSACTION_VIOLATION_TAB_DETAILS: {
route: 'debug/transaction/:transactionID/violations/:index/details',
getRoute: (transactionID: string, index: string) => `debug/transaction/${transactionID}/violations/${index}/details` as const,
},
DEBUG_TRANSACTION_VIOLATION_TAB_JSON: {
route: 'debug/transaction/:transactionID/violations/:index/json',
getRoute: (transactionID: string, index: string) => `debug/transaction/${transactionID}/violations/${index}/json` as const,
},
} as const;

/**
Expand Down
3 changes: 3 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,9 @@ const SCREENS = {
REPORT_ACTION_CREATE: 'Debug_Report_Action_Create',
DETAILS_CONSTANT_PICKER_PAGE: 'Debug_Details_Constant_Picker_Page',
DETAILS_DATE_TIME_PICKER_PAGE: 'Debug_Details_Date_Time_Picker_Page',
TRANSACTION: 'Debug_Transaction',
TRANSACTION_VIOLATION_CREATE: 'Debug_Transaction_Violation_Create',
TRANSACTION_VIOLATION: 'Debug_Transaction_Violation',
},
} as const;

Expand Down
12 changes: 4 additions & 8 deletions src/components/CurrencySelectionList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import {Str} from 'expensify-common';
import React, {useCallback, useMemo, useState} from 'react';
import {withOnyx} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
import SelectionList from '@components/SelectionList';
import RadioListItem from '@components/SelectionList/RadioListItem';
import SelectableListItem from '@components/SelectionList/SelectableListItem';
import useLocalize from '@hooks/useLocalize';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import ONYXKEYS from '@src/ONYXKEYS';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import type {CurrencyListItem, CurrencySelectionListOnyxProps, CurrencySelectionListProps} from './types';
import type {CurrencyListItem, CurrencySelectionListProps} from './types';

function CurrencySelectionList({
searchInputLabel,
initiallySelectedCurrencyCode,
onSelect,
currencyList,
selectedCurrencies = [],
canSelectMultiple = false,
recentlyUsedCurrencies,
}: CurrencySelectionListProps) {
const [currencyList] = useOnyx(ONYXKEYS.CURRENCY_LIST);
const [searchValue, setSearchValue] = useState('');
const {translate} = useLocalize();
const getUnselectedOptions = useCallback((options: CurrencyListItem[]) => options.filter((option) => !option.isSelected), []);
Expand Down Expand Up @@ -107,8 +107,4 @@ function CurrencySelectionList({

CurrencySelectionList.displayName = 'CurrencySelectionList';

const CurrencySelectionListWithOnyx = withOnyx<CurrencySelectionListProps, CurrencySelectionListOnyxProps>({
currencyList: {key: ONYXKEYS.CURRENCY_LIST},
})(CurrencySelectionList);

export default CurrencySelectionListWithOnyx;
export default CurrencySelectionList;
11 changes: 2 additions & 9 deletions src/components/CurrencySelectionList/types.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import type {OnyxEntry} from 'react-native-onyx';
import type {ListItem} from '@components/SelectionList/types';
import type {CurrencyList} from '@src/types/onyx';

type CurrencyListItem = ListItem & {
currencyName: string;
currencyCode: string;
};

type CurrencySelectionListOnyxProps = {
/** List of available currencies */
currencyList: OnyxEntry<CurrencyList>;
};

type CurrencySelectionListProps = CurrencySelectionListOnyxProps & {
type CurrencySelectionListProps = {
/** Label for the search text input */
searchInputLabel: string;

Expand All @@ -32,4 +25,4 @@ type CurrencySelectionListProps = CurrencySelectionListOnyxProps & {
canSelectMultiple?: boolean;
};

export type {CurrencyListItem, CurrencySelectionListProps, CurrencySelectionListOnyxProps};
export type {CurrencyListItem, CurrencySelectionListProps};
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/MoneyReportView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function MoneyReportView({report, policy, isCombinedReport = false, shouldShowTo
return (
<OfflineWithFeedback
// Need to return undefined when we have pendingAction to avoid the duplicate pending action
pendingAction={pendingAction ? undefined : report.pendingFields?.[fieldKey]}
pendingAction={pendingAction ? undefined : report.pendingFields?.[fieldKey as keyof typeof report.pendingFields]}
errors={report.errorFields?.[fieldKey]}
errorRowStyles={styles.ph5}
key={`menuItem-${fieldKey}`}
Expand Down
2 changes: 2 additions & 0 deletions src/components/TabSelector/TabSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ function getIconAndTitle(route: string, translate: LocaleContextProps['translate
return {icon: Expensicons.Document, title: translate('debug.reportActions')};
case CONST.DEBUG.REPORT_ACTION_PREVIEW:
return {icon: Expensicons.Document, title: translate('debug.reportActionPreview')};
case CONST.DEBUG.TRANSACTION_VIOLATIONS:
return {icon: Expensicons.Exclamation, title: translate('debug.violations')};
case CONST.TAB_REQUEST.MANUAL:
return {icon: Expensicons.Pencil, title: translate('tabSelector.manual')};
case CONST.TAB_REQUEST.SCAN:
Expand Down
29 changes: 18 additions & 11 deletions src/components/TagPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ type TagPickerProps = {
/** Should show the selected option that is disabled? */
shouldShowDisabledAndSelectedOption?: boolean;

/** Whether the list should be sorted by tag name. default is false */
shouldOrderListByTagName?: boolean;
pac-guerreiro marked this conversation as resolved.
Show resolved Hide resolved

/** Indicates which tag list index was selected */
tagListIndex: number;
};

function TagPicker({selectedTag, tagListName, policyID, tagListIndex, shouldShowDisabledAndSelectedOption = false, onSubmit}: TagPickerProps) {
function TagPicker({selectedTag, tagListName, policyID, tagListIndex, shouldShowDisabledAndSelectedOption = false, shouldOrderListByTagName = false, onSubmit}: TagPickerProps) {
const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`);
const [policyRecentlyUsedTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS}${policyID}`);
const styles = useThemeStyles();
Expand Down Expand Up @@ -72,16 +75,20 @@ function TagPicker({selectedTag, tagListName, policyID, tagListIndex, shouldShow
return [...selectedOptions, ...Object.values(policyTagList.tags).filter((policyTag) => policyTag.enabled && !selectedNames.includes(policyTag.name))];
}, [selectedOptions, policyTagList, shouldShowDisabledAndSelectedOption]);

const sections = useMemo(
() =>
TagOptionListUtils.getTagListSections({
searchValue,
selectedOptions,
tags: enabledTags,
recentlyUsedTags: policyRecentlyUsedTagsList,
}),
[searchValue, enabledTags, selectedOptions, policyRecentlyUsedTagsList],
);
const sections = useMemo(() => {
const tagSections = TagOptionListUtils.getTagListSections({
searchValue,
selectedOptions,
tags: enabledTags,
recentlyUsedTags: policyRecentlyUsedTagsList,
});
return shouldOrderListByTagName
? tagSections.map((option) => ({
...option,
data: option.data.sort((a, b) => a.text?.localeCompare(b.text ?? '') ?? 0),
}))
: tagSections;
}, [searchValue, selectedOptions, enabledTags, policyRecentlyUsedTagsList, shouldOrderListByTagName]);

const headerMessage = OptionsListUtils.getHeaderMessageForNonUserList((sections?.at(0)?.data?.length ?? 0) > 0, searchValue);

Expand Down
5 changes: 5 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5328,6 +5328,9 @@ const translations = {
createReportAction: 'Create Report Action',
reportAction: 'Report Action',
report: 'Report',
transaction: 'Transaction',
violations: 'Violations',
transactionViolation: 'Transaction Violation',
hint: "Data changes won't be sent to the backend",
textFields: 'Text fields',
numberFields: 'Number fields',
Expand All @@ -5343,6 +5346,8 @@ const translations = {
true: 'true',
false: 'false',
viewReport: 'View Report',
viewTransaction: 'View transaction',
createTransactionViolation: 'Create transaction violation',
reasonVisibleInLHN: {
hasDraftComment: 'Has draft comment',
hasGBR: 'Has GBR',
Expand Down
5 changes: 5 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5847,6 +5847,9 @@ const translations = {
createReportAction: 'Crear Report Action',
reportAction: 'Report Action',
report: 'Report',
transaction: 'Transacción',
violations: 'Violaciones',
transactionViolation: 'Violación de transacción',
hint: 'Los cambios de datos no se enviarán al backend',
textFields: 'Campos de texto',
numberFields: 'Campos numéricos',
Expand All @@ -5862,6 +5865,8 @@ const translations = {
true: 'verdadero',
false: 'falso',
viewReport: 'Ver Informe',
viewTransaction: 'Ver transacción',
createTransactionViolation: 'Crear infracción de transacción',
reasonVisibleInLHN: {
hasDraftComment: 'Tiene comentario en borrador',
hasGBR: 'Tiene GBR',
Expand Down
Loading
Loading