Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7c72eee
Send [] as the inputs of a Wise page whose only answers are files
mikolajpochec Nov 2, 2026
99a46c1
Support Wise enhanced due diligence
mikolajpochec Nov 2, 2026
fd5730d
Merge remote-tracking branch 'upstream/main' into @mikolajpochec/wise…
mikolajpochec Nov 2, 2026
46ce029
Say sensitive answers reach the screen as a separate argument
mikolajpochec Nov 2, 2026
fd2b38b
Read the Wise requirements on a direct link to an onboarding page
mikolajpochec Nov 2, 2026
4f29c0a
Merge remote-tracking branch 'upstream/main' into @mikolajpochec/wise…
mikolajpochec Nov 2, 2026
1dc1a9e
Merge remote-tracking branch 'upstream/main' into @mikolajpochec/wise…
mikolajpochec Nov 4, 2026
c3b8a44
Support Wise enhanced due diligence documents
mikolajpochec Nov 6, 2026
03d48f3
Show source of wealth documents for every picked source
mikolajpochec Nov 12, 2026
a5f3fbe
Merge upstream/main into @mikolajpochec/wise-enhanced-due-diligence
mikolajpochec Nov 12, 2026
0d3d4a1
Fix knip and typecheck after main merge
mikolajpochec Nov 12, 2026
b374cde
Send empty inputs as an object
mikolajpochec Nov 12, 2026
f1ef05e
Send isSourceOfFund for every picked source
mikolajpochec Nov 12, 2026
cf4788a
Show a hint under the bank statement button
mikolajpochec Nov 12, 2026
3ada34e
Show a spinner after the business page while it saves
mikolajpochec Nov 13, 2026
fd61442
Mention the bank statement in the source hints
mikolajpochec Nov 13, 2026
027b932
Ask the daily operations page again once a second source is picked
mikolajpochec Nov 13, 2026
9e0062b
Take the same file under two upload buttons
mikolajpochec Nov 13, 2026
5990b18
Merge remote-tracking branch 'upstream/main' into @mikolajpochec/wise…
mikolajpochec Nov 13, 2026
f7c217c
Scroll the document type menu
mikolajpochec Nov 16, 2026
6990f6a
Drop the extra margins in the document type menu
mikolajpochec Nov 16, 2026
d07eb56
Ask the daily operations page again after a source is added
mikolajpochec Nov 16, 2026
f8867e1
Show the user's file name for saved files
mikolajpochec Nov 16, 2026
435cbb3
Say when a file with the same name is left out
mikolajpochec Nov 16, 2026
be6a7a0
Cap the new files of one save at 20
mikolajpochec Nov 16, 2026
b5c4c3e
Count the file limit across a source's buttons
mikolajpochec Nov 16, 2026
d59f99a
Compare new files by their own names
mikolajpochec Nov 16, 2026
5dac81e
Merge remote-tracking branch 'upstream/main' into @mikolajpochec/wise…
mikolajpochec Nov 16, 2026
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
1 change: 0 additions & 1 deletion config/oxlint/oxlint.seatbelt.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,6 @@
"../../src/components/TransactionItemRow/DataCells/ChatBubbleCell.tsx" "rulesdir/no-raw-typography" 2
"../../src/components/TransactionItemRow/DataCells/MerchantCell.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/UnitPicker.tsx" "@typescript-eslint/no-unnecessary-type-assertion" 1
"../../src/components/UploadFile.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/UserInitialsAvatar.tsx" "@typescript-eslint/no-deprecated/fontSize" 1
"../../src/components/ValidateCodeActionModal/ValidateCodeActionContent.tsx" "rulesdir/no-onyx-loading-status" 1
"../../src/components/ValidateCodeInput.tsx" "react-hooks/set-state-in-effect" 3
Expand Down
45 changes: 45 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,51 @@ const CONST = {
/** Wise's KYC requirement types we collect */
KYC_REQUIREMENT: {
ID_DOCUMENT: 'ID_DOCUMENT',
BUSINESS_SOURCE_OF_WEALTH_INFO: 'BUSINESS_SOURCE_OF_WEALTH_INFO',
BUSINESS_SOURCE_OF_WEALTH_PROOF: 'BUSINESS_SOURCE_OF_WEALTH_PROOF',
},
/** The source of funds page's answer key, which is Wise's field */
SOURCE_OF_WEALTH_INFO_KEY: 'businessSourceOfWealthInfo',
/** The key Wise takes the picked sources under, one `{businessSourceOfWealthInfo, isSourceOfFund}` entry per source */
SOURCE_OF_WEALTH_LIST_KEY: 'sourceOfWealthList',
/** The daily operations page's answer key: the picked sources that fund the business's daily operations, saved as each entry's `isSourceOfFund` */
SOURCE_OF_FUNDS_KEY: 'sourceOfFunds',
/** Drafted as true while a newly picked source waits for the daily operations page, since the new source can fund daily operations too */
SOURCE_OF_FUNDS_REVIEW_KEY: 'shouldReviewSourceOfFunds',
/** The server takes up to this many files in one save and drops the rest without an error */
MAX_NEW_FILES_PER_SAVE: 20,
/** Wise's businessSourceOfWealthInfo values, in Wise's order */
SOURCE_OF_WEALTH: {
REVENUE: 'REVENUE',
PERSONAL_FUNDING: 'PERSONAL_FUNDING',
BUSINESS_LOAN: 'BUSINESS_LOAN',
FUNDING_AND_SHAREHOLDER_INVESTMENTS: 'FUNDING_AND_SHAREHOLDER_INVESTMENTS',
INVESTMENT_INCOME: 'INVESTMENT_INCOME',
DONATIONS: 'DONATIONS',
GRANTS: 'GRANTS',
LEGAL: 'LEGAL',
},
/** Wise's documentType values for a BUSINESS_SOURCE_OF_WEALTH_PROOF document */
SOURCE_OF_WEALTH_DOCUMENT_TYPE: {
TAX_DOCUMENTS: 'TAX_DOCUMENTS',
AUDITED_FINANCIAL_STATEMENTS: 'AUDITED_FINANCIAL_STATEMENTS',
BANK_STATEMENT: 'BANK_STATEMENT',
E_COMMERCE_STATEMENTS: 'E_COMMERCE_STATEMENTS',
INVOICES: 'INVOICES',
CONTRACTS: 'CONTRACTS',
PERSONAL_TAX_DECLARATION: 'PERSONAL_TAX_DECLARATION',
SAVINGS_STATEMENT: 'SAVINGS_STATEMENT',
PAYSLIP: 'PAYSLIP',
PERSONAL_LOAN_AGREEMENT: 'PERSONAL_LOAN_AGREEMENT',
PERSONAL_INVESTMENT: 'PERSONAL_INVESTMENT',
ASSET_SALE_AGREEMENT: 'ASSET_SALE_AGREEMENT',
LOAN_AGREEMENT: 'LOAN_AGREEMENT',
EQUITY_AGREEMENT: 'EQUITY_AGREEMENT',
SUBSCRIPTION_AGREEMENT: 'SUBSCRIPTION_AGREEMENT',
SHARE_SALE_CERTIFICATE: 'SHARE_SALE_CERTIFICATE',
DONATION_RECEIPTS: 'DONATION_RECEIPTS',
WRITTEN_CONFIRMATION: 'WRITTEN_CONFIRMATION',
GRANT_APPROVAL_LETTER: 'GRANT_APPROVAL_LETTER',
},
/** Wise's companyType values, the legal form */
COMPANY_TYPE: {
Expand Down
13 changes: 4 additions & 9 deletions src/components/DynamicForm/adapters/FileUploadAdapter.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import FormContext from '@components/Form/FormContext';
import useUploadErrorAnnouncement from '@components/DynamicForm/hooks/useUploadErrorAnnouncement';
import FSClassView from '@components/FSClassView';
import UploadFile from '@components/UploadFile';

import useAccessibilityAnnouncement from '@hooks/useAccessibilityAnnouncement';

import type {ForwardedFSClassProps} from '@libs/Fullstory/types';

import type {FileObject} from '@src/types/utils/Attachment';

import type {ComponentProps, ComponentRef, Ref} from 'react';
import type {View} from 'react-native';

import React, {useContext, useState} from 'react';
import React, {useState} from 'react';

/** UploadFile settings the adapter passes through unchanged */
type UploadFileSettings = Pick<ComponentProps<typeof UploadFile>, 'buttonText' | 'acceptedFileTypes' | 'fileLimit' | 'maxFileSize' | 'accessibilityLabel'>;
Expand All @@ -36,11 +34,7 @@ function FileUploadAdapter({value, onInputChange = () => {}, errorText = '', for
const [uploadError, setUploadError] = useState('');
const files = Array.isArray(value) ? value : [];

const shownError = uploadError || errorText;
const {getErrorAnnouncementKey} = useContext(FormContext);
const errorAnnouncementKey = getErrorAnnouncementKey();
// UploadFile shows the error through a live region, which VoiceOver ignores, so it is announced as it appears and again on each submit
useAccessibilityAnnouncement(shownError, !!shownError, {shouldAnnounceOnNative: true, announcementKey: errorAnnouncementKey});
const shownError = useUploadErrorAnnouncement(uploadError, errorText);

// UploadFile takes no FullStory class, so the mask goes on a View around it
return (
Expand All @@ -65,3 +59,4 @@ function FileUploadAdapter({value, onInputChange = () => {}, errorText = '', for
}

export default FileUploadAdapter;
export type {UploadFileSettings};
194 changes: 194 additions & 0 deletions src/components/DynamicForm/adapters/LabelledFileUploadAdapter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
import Button from '@components/Button';
import DotIndicatorMessage from '@components/DotIndicatorMessage';
import FileTypeMenuButton from '@components/DynamicForm/components/FileTypeMenuButton';
import type {FileTypeOption} from '@components/DynamicForm/components/FileTypeMenuButton';
import useUploadErrorAnnouncement from '@components/DynamicForm/hooks/useUploadErrorAnnouncement';
import {getListItemFiles, getListItems} from '@components/DynamicForm/utils/listItems';
import FSClassView from '@components/FSClassView';
import Text from '@components/Text';
import UploadedFileChip from '@components/UploadFile/components/UploadedFileChip';
import UploadFilePicker from '@components/UploadFile/components/UploadFilePicker';

import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';

import type {ForwardedFSClassProps} from '@libs/Fullstory/types';

import CONST from '@src/CONST';
import type {DynamicFormListItem} from '@src/types/onyx';
import type {FileObject} from '@src/types/utils/Attachment';

import type {ComponentRef, Ref} from 'react';

import React, {useState} from 'react';
import {View} from 'react-native';

import type {UploadFileSettings} from './FileUploadAdapter';

/** One upload button and the kinds of document it takes */
type LabelledUpload = {
/** The kinds of document the button takes */
types: FileTypeOption[];

/** Text of the button */
buttonText: string;

/** Hint under the button, such as what the document must show */
description?: string;
};

type LabelledFileUploadAdapterProps = Omit<UploadFileSettings, 'buttonText'> &
ForwardedFSClassProps & {
/** One entry per kind of document used so far: `{id, fileType, files}` */
value?: DynamicFormListItem[];

/** Called with every entry after each add or remove */
onInputChange?: (value: DynamicFormListItem[]) => void;

/** Validation error, shown under each button that has no file yet, or under the last button when every button has one */
errorText?: string;

/** The upload buttons, in order */
uploads: LabelledUpload[];

/** Lets FormProvider scroll to the field when the user asks to fix the errors */
ref?: Ref<ComponentRef<typeof View>>;
};

/**
* Upload buttons, each labelling its files with a kind of document it takes. A button with one kind opens the file picker, and a button with more asks which kind first.
* Files list under their button. The file limit counts every file of the field, and the check for a file with the same name only the button's own files, since one file can prove two documents.
*/
function LabelledFileUploadAdapter({
value,
onInputChange = () => {},
errorText = '',
uploads,
forwardedFSClass,
ref,
accessibilityLabel,
acceptedFileTypes,
fileLimit,
maxFileSize,
}: LabelledFileUploadAdapterProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const [uploadError, setUploadError] = useState('');
const [uploadErrorIndex, setUploadErrorIndex] = useState<number>();
const entries = getListItems(value);
// Announces the upload error, else the validation error, as it appears
useUploadErrorAnnouncement(uploadError, errorText);

const getFiles = (upload: LabelledUpload) => entries.filter((entry) => upload.types.some((type) => type.value === entry.fileType));
const hasFileUnderEveryButton = uploads.every((upload) => getFiles(upload).length > 0);
const getTypeLabel = (fileType: unknown) => uploads.flatMap((upload) => upload.types).find((type) => type.value === fileType)?.label ?? '';

const addFiles = (index: number, fileType: string, newFiles: FileObject[]) => {
if (newFiles.length === 0) {
return;
}
// The picker checks the limit against the button's own files, so the field checks it against all of them
if (fileLimit && entries.flatMap(getListItemFiles).length + newFiles.length > fileLimit) {
setUploadErrorIndex(index);
setUploadError(translate('attachmentPicker.tooManyFiles', fileLimit));
return;
}
const typeEntry = entries.find((entry) => entry.fileType === fileType);
const updatedEntry: DynamicFormListItem = {id: fileType, fileType, files: [...(typeEntry ? getListItemFiles(typeEntry) : []), ...newFiles]};
onInputChange(typeEntry ? entries.map((entry) => (entry === typeEntry ? updatedEntry : entry)) : [...entries, updatedEntry]);
};

const removeFile = (removedEntry: DynamicFormListItem, fileName: string) => {
setUploadError('');
const files = getListItemFiles(removedEntry).filter((file) => file.name !== fileName);
onInputChange(files.length > 0 ? entries.map((entry) => (entry === removedEntry ? {...entry, files} : entry)) : entries.filter((entry) => entry !== removedEntry));
};

return (
<FSClassView
ref={ref}
forwardedFSClass={forwardedFSClass}
>
{uploads.map((upload, index) => {
const uploadEntries = getFiles(upload);
const buttonAccessibilityLabel = accessibilityLabel ? `${upload.buttonText}, ${accessibilityLabel}` : upload.buttonText;
let shownError = '';
if (uploadErrorIndex === index && uploadError) {
shownError = uploadError;
} else if (uploadEntries.length === 0 || (hasFileUnderEveryButton && index === uploads.length - 1)) {
shownError = errorText;
}
return (
<View
// The buttons are fixed by the schema, so their order keys them
// eslint-disable-next-line react/no-array-index-key
key={index}
style={[index > 0 && styles.mt5, styles.alignItemsStart]}
>
<UploadFilePicker
buttonText={upload.buttonText}
existingFiles={uploadEntries.flatMap(getListItemFiles)}
setError={(error) => {
setUploadErrorIndex(index);
setUploadError(error);
}}
fileLimit={fileLimit}
acceptedFileTypes={acceptedFileTypes}
maxFileSize={maxFileSize}
>
{(openPicker) => {
const [onlyType] = upload.types;
if (upload.types.length === 1 && onlyType) {
return (
<Button
sentryLabel={CONST.SENTRY_LABEL.UPLOAD_FILE.UPLOAD_BUTTON}
accessibilityLabel={buttonAccessibilityLabel}
onPress={() => openPicker((files) => addFiles(index, onlyType.value, files))}
>
<Button.Text>{upload.buttonText}</Button.Text>
</Button>
);
}
return (
<FileTypeMenuButton
buttonText={upload.buttonText}
accessibilityLabel={buttonAccessibilityLabel}
types={upload.types}
onSelect={(fileType) => openPicker((files) => addFiles(index, fileType, files))}
/>
);
}}
</UploadFilePicker>
{uploadEntries.map((entry) => (
// Full width, so a long file name is cut short instead of pushing the remove button out of view
<View
key={entry.id}
style={[styles.mt3, styles.w100, styles.alignItemsStart]}
>
{upload.types.length > 1 && <Text style={styles.textLabelSupporting}>{getTypeLabel(entry.fileType)}</Text>}
{getListItemFiles(entry).map((file) => (
<UploadedFileChip
key={file.name}
file={file}
onRemove={(fileName) => removeFile(entry, fileName)}
shouldExtendRemoveTouchArea
/>
))}
</View>
))}
{!!upload.description && <Text style={[styles.textLabelSupporting, styles.mt2]}>{upload.description}</Text>}
{!!shownError && (
<DotIndicatorMessage
style={[styles.formError, styles.mt3]}
type="error"
messages={{shownError}}
/>
)}
</View>
);
})}
</FSClassView>
);
}

export default LabelledFileUploadAdapter;
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function DynamicFormFieldsPage({
isRefreshingRequirements,
refreshError,
shouldDisableNextWhenOffline,
validatePage,
}: DynamicFormSubPageProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
Expand All @@ -58,7 +59,11 @@ function DynamicFormFieldsPage({
<FormProvider
formID={formID}
submitButtonText={translate(isEditing || isLastPage ? 'common.confirm' : 'common.next')}
validate={(inputValues) => getDynamicFieldErrors(getContentFields(page.content), withInputValues(inputValues), translate, allFields)}
validate={(inputValues) => {
const currentValues = withInputValues(inputValues);
// A field's own error, such as a missing answer, says more than a check of the whole page
return {...validatePage?.(page, currentValues), ...getDynamicFieldErrors(getContentFields(page.content), currentValues, translate, allFields)};
}}
onSubmit={(inputValues) => {
const pageValues = toDynamicFormValues(inputValues);
onPageSubmit(page, pageValues);
Expand Down
Loading
Loading