Skip to content

[Report Creation UI] Create entrypoint for Report creation flow. #57847

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

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
3 changes: 2 additions & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ const CONST = {
NEWDOT_INTERNATIONAL_DEPOSIT_BANK_ACCOUNT: 'newDotInternationalDepositBankAccount',
NSQS: 'nsqs',
CUSTOM_RULES: 'customRules',
TABLE_REPORT_VIEW: 'tableReportView',
},
BUTTON_STATES: {
DEFAULT: 'default',
Expand Down Expand Up @@ -3320,7 +3321,7 @@ const CONST = {
`(?<!^[^\`\n]*(?:\`[^\`\n]*\`[^\`\n]*)*\`[^\`\n]*)@[\\w\\-\\+\\'#@]+(?:\\.[\\w\\-\\'\\+]+)*|@[\\w\\-\\+\\'#@]+(?:\\.[\\w\\-\\'\\+]+)*(?![^\n]*\`)`,
'gim',
),
REPORT_ID_FROM_PATH: /\/r\/(\d+)/,
REPORT_ID_FROM_PATH: /(?<!\/search)\/r\/(\d+)/,
DISTANCE_MERCHANT: /^[0-9.]+ \w+ @ (-|-\()?[^0-9.\s]{1,3} ?[0-9.]+\)? \/ \w+$/,
WHITESPACE: /\s+/g,

Expand Down
5 changes: 3 additions & 2 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ const ROUTES = {
},
},
SEARCH_MONEY_REQUEST_REPORT: {
route: 'search/report/:reportID',
route: 'search/r/:reportID',
getRoute: ({reportID, backTo}: {reportID: string; backTo?: string}) => {
const baseRoute = `search/view/${reportID}` as const;
const baseRoute = `search/r/${reportID}` as const;
return getUrlWithBackToParam(baseRoute, backTo);
},
},
Expand Down Expand Up @@ -314,6 +314,7 @@ const ROUTES = {
NEW_CHAT_EDIT_NAME: 'new/chat/confirm/name/edit',
NEW_ROOM: 'new/room',

NEW_REPORT_WORKSPACE_SELECTION: 'new-report-workspace-selection',
REPORT: 'r',
REPORT_WITH_ID: {
route: 'r/:reportID?/:reportActionID?',
Expand Down
5 changes: 5 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ const SCREENS = {
NEW_CHAT: 'NewChat',
DETAILS: 'Details',
PROFILE: 'Profile',
NEW_REPORT_WORKSPACE_SELECTION: 'New_Report_Workspace_Selection',
REPORT_DETAILS: 'Report_Details',
WORKSPACE_CONFIRMATION: 'Workspace_Confirmation',
REPORT_SETTINGS: 'Report_Settings',
Expand Down Expand Up @@ -327,6 +328,10 @@ const SCREENS = {
EDIT: 'PrivateNotes_Edit',
},

NEW_REPORT_WORKSPACE_SELECTION: {
ROOT: 'NewReportWorkspaceSelection_Root',
},

REPORT_DETAILS: {
ROOT: 'Report_Details_Root',
SHARE_CODE: 'Report_Details_Share_Code',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5143,6 +5143,10 @@ const translations = {
},
},
report: {
newReport: {
createReport: 'Create report',
chooseWorkspace: 'Choose a workspace for this report.',
},
genericCreateReportFailureMessage: 'Unexpected error creating this chat. Please try again later.',
genericAddCommentFailureMessage: 'Unexpected error posting the comment. Please try again later.',
genericUpdateReportFieldFailureMessage: 'Unexpected error updating the field. Please try again later.',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5198,6 +5198,10 @@ const translations = {
},
},
report: {
newReport: {
createReport: 'Crear informe',
chooseWorkspace: 'Elige un espacio de trabajo para este informe.',
},
genericCreateReportFailureMessage: 'Error inesperado al crear el chat. Por favor, inténtalo más tarde.',
genericAddCommentFailureMessage: 'Error inesperado al añadir el comentario. Por favor, inténtalo más tarde.',
genericUpdateReportFieldFailureMessage: 'Error inesperado al actualizar el campo. Por favor, inténtalo más tarde.',
Expand Down
8 changes: 8 additions & 0 deletions src/libs/API/parameters/CreateAppReportParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type CreateAppReportParams = {
reportName: string;
policyID?: string;
type: string;
reportID: string;
reportActionID: string;
};
export default CreateAppReportParams;
1 change: 1 addition & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type {default as GetOlderActionsParams} from './GetOlderActionsParams';
export type {default as GetPolicyCategoriesParams} from './GetPolicyCategories';
export type {default as GetReportPrivateNoteParams} from './GetReportPrivateNoteParams';
export type {default as GetRouteParams} from './GetRouteParams';
export type {default as CreateAppReportParams} from './CreateAppReportParams';
export type {default as GetStatementPDFParams} from './GetStatementPDFParams';
export type {default as HandleRestrictedEventParams} from './HandleRestrictedEventParams';
export type {default as LogOutParams} from './LogOutParams';
Expand Down
2 changes: 2 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const WRITE_COMMANDS = {
TOGGLE_PINNED_CHAT: 'TogglePinnedChat',
DELETE_COMMENT: 'DeleteComment',
UPDATE_COMMENT: 'UpdateComment',
CREATE_APP_REPORT: 'CreateAppReport',
UPDATE_REPORT_NOTIFICATION_PREFERENCE: 'UpdateReportNotificationPreference',
UPDATE_ROOM_VISIBILITY: 'UpdateRoomVisibility',
UPDATE_ROOM_DESCRIPTION: 'UpdateRoomDescription',
Expand Down Expand Up @@ -544,6 +545,7 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.DISABLE_TWO_FACTOR_AUTH]: Parameters.DisableTwoFactorAuthParams;
[WRITE_COMMANDS.ADD_COMMENT]: Parameters.AddCommentOrAttachementParams;
[WRITE_COMMANDS.ADD_ATTACHMENT]: Parameters.AddCommentOrAttachementParams;
[WRITE_COMMANDS.CREATE_APP_REPORT]: Parameters.CreateAppReportParams;
[WRITE_COMMANDS.ADD_TEXT_AND_ATTACHMENT]: Parameters.AddCommentOrAttachementParams;
[WRITE_COMMANDS.CONNECT_BANK_ACCOUNT_WITH_PLAID]: Parameters.ConnectBankAccountParams;
[WRITE_COMMANDS.ADD_PERSONAL_BANK_ACCOUNT]: Parameters.AddPersonalBankAccountParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
MissingPersonalDetailsParamList,
MoneyRequestNavigatorParamList,
NewChatNavigatorParamList,
NewReportWorkspaceSelectionNavigatorParamList,
NewTaskNavigatorParamList,
ParticipantsNavigatorParamList,
PrivateNotesNavigatorParamList,
Expand Down Expand Up @@ -128,6 +129,10 @@ const ProfileModalStackNavigator = createModalStackNavigator<ProfileNavigatorPar
[SCREENS.PROFILE_ROOT]: () => require<ReactComponentModule>('../../../../pages/ProfilePage').default,
});

const NewReportWorkspaceSelectionModalStackNavigator = createModalStackNavigator<NewReportWorkspaceSelectionNavigatorParamList>({
[SCREENS.NEW_REPORT_WORKSPACE_SELECTION.ROOT]: () => require<ReactComponentModule>('../../../../pages/NewReportWorkspaceSelectionPage').default,
});

const ReportDetailsModalStackNavigator = createModalStackNavigator<ReportDetailsNavigatorParamList>({
[SCREENS.REPORT_DETAILS.ROOT]: () => require<ReactComponentModule>('../../../../pages/ReportDetailsPage').default,
[SCREENS.REPORT_DETAILS.SHARE_CODE]: () => require<ReactComponentModule>('../../../../pages/home/report/ReportDetailsShareCodePage').default,
Expand Down Expand Up @@ -738,6 +743,7 @@ export {
ReferralModalStackNavigator,
TravelModalStackNavigator,
ReimbursementAccountModalStackNavigator,
NewReportWorkspaceSelectionModalStackNavigator,
ReportDescriptionModalStackNavigator,
ReportDetailsModalStackNavigator,
ReportParticipantsModalStackNavigator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) {
name={SCREENS.RIGHT_MODAL.DEBUG}
component={ModalStackNavigators.DebugModalStackNavigator}
/>
<Stack.Screen
name={SCREENS.RIGHT_MODAL.NEW_REPORT_WORKSPACE_SELECTION}
component={ModalStackNavigators.NewReportWorkspaceSelectionModalStackNavigator}
/>
<Stack.Screen
name={SCREENS.RIGHT_MODAL.REPORT_DETAILS}
component={ModalStackNavigators.ReportDetailsModalStackNavigator}
Expand Down
5 changes: 5 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,11 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
[SCREENS.PRIVATE_NOTES.EDIT]: ROUTES.PRIVATE_NOTES_EDIT.route,
},
},
[SCREENS.RIGHT_MODAL.NEW_REPORT_WORKSPACE_SELECTION]: {
screens: {
[SCREENS.NEW_REPORT_WORKSPACE_SELECTION.ROOT]: ROUTES.NEW_REPORT_WORKSPACE_SELECTION,
},
},
[SCREENS.RIGHT_MODAL.REPORT_DETAILS]: {
screens: {
[SCREENS.REPORT_DETAILS.ROOT]: ROUTES.REPORT_WITH_ID_DETAILS.route,
Expand Down
6 changes: 6 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,10 @@ type ProfileNavigatorParamList = {
};
};

type NewReportWorkspaceSelectionNavigatorParamList = {
[SCREENS.NEW_REPORT_WORKSPACE_SELECTION.ROOT]: undefined;
};

type ReportDetailsNavigatorParamList = {
[SCREENS.REPORT_DETAILS.ROOT]: {
reportID: string;
Expand Down Expand Up @@ -1529,6 +1533,7 @@ type RightModalNavigatorParamList = {
[SCREENS.RIGHT_MODAL.DETAILS]: NavigatorScreenParams<DetailsNavigatorParamList>;
[SCREENS.RIGHT_MODAL.PROFILE]: NavigatorScreenParams<ProfileNavigatorParamList>;
[SCREENS.SETTINGS.SHARE_CODE]: undefined;
[SCREENS.RIGHT_MODAL.NEW_REPORT_WORKSPACE_SELECTION]: NavigatorScreenParams<NewReportWorkspaceSelectionNavigatorParamList>;
[SCREENS.RIGHT_MODAL.REPORT_DETAILS]: NavigatorScreenParams<ReportDetailsNavigatorParamList>;
[SCREENS.RIGHT_MODAL.REPORT_SETTINGS]: NavigatorScreenParams<ReportSettingsNavigatorParamList>;
[SCREENS.RIGHT_MODAL.SETTINGS_CATEGORIES]: NavigatorScreenParams<SettingsNavigatorParamList>;
Expand Down Expand Up @@ -1961,6 +1966,7 @@ export type {
PublicScreensParamList,
ReferralDetailsNavigatorParamList,
ReimbursementAccountNavigatorParamList,
NewReportWorkspaceSelectionNavigatorParamList,
ReportDescriptionNavigatorParamList,
ReportDetailsNavigatorParamList,
ReportSettingsNavigatorParamList,
Expand Down
5 changes: 5 additions & 0 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ function canUseCustomRules(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.CUSTOM_RULES) || canUseAllBetas(betas);
}

function canUseTableReportView(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.TABLE_REPORT_VIEW) || canUseAllBetas(betas);
}

export default {
canUseDefaultRooms,
canUseLinkPreviews,
Expand All @@ -61,4 +65,5 @@ export default {
canUseInternationalBankAccount,
canUseNSQS,
canUseCustomRules,
canUseTableReportView,
};
11 changes: 5 additions & 6 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1213,12 +1213,11 @@ function isPolicyAccessible(policy: OnyxEntry<Policy>): boolean {
);
}

function areAllGroupPoliciesExpenseChatDisabled(policies = allPolicies) {
const groupPolicies = Object.values(policies ?? {}).filter((policy) => isPaidGroupPolicy(policy));
if (groupPolicies.length === 0) {
return false;
function getGroupPaidPoliciesWithExpenseChatEnabled(policies: OnyxCollection<Policy> | null = allPolicies) {
if (isEmptyObject(policies)) {
return CONST.EMPTY_ARRAY;
}
return !groupPolicies.some((policy) => !!policy?.isPolicyExpenseChatEnabled);
return Object.values(policies).filter((policy) => isPaidGroupPolicy(policy) && policy?.isPolicyExpenseChatEnabled);
}

// eslint-disable-next-line rulesdir/no-negated-variables
Expand Down Expand Up @@ -1495,6 +1494,7 @@ export {
getCurrentTaxID,
areSettingsInErrorFields,
settingsPendingAction,
getGroupPaidPoliciesWithExpenseChatEnabled,
getForwardsToAccount,
getSubmitToAccountID,
getWorkspaceAccountID,
Expand All @@ -1509,7 +1509,6 @@ export {
getActivePolicy,
getUserFriendlyWorkspaceType,
isPolicyAccessible,
areAllGroupPoliciesExpenseChatDisabled,
shouldDisplayPolicyNotFoundPage,
hasOtherControlWorkspaces,
getManagerAccountEmail,
Expand Down
20 changes: 20 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,24 @@ type OptimisticExpenseReport = Pick<
| 'fieldList'
>;

type OptimisticNewReport = Pick<
Report,
| 'reportID'
| 'policyID'
| 'type'
| 'ownerAccountID'
| 'reportName'
| 'stateNum'
| 'statusNum'
| 'total'
| 'nonReimbursableTotal'
| 'parentReportID'
| 'lastVisibleActionCreated'
| 'parentReportActionID'
| 'participants'
| 'managerID'
>;

type OptimisticIOUReportAction = Pick<
ReportAction,
| 'actionName'
Expand Down Expand Up @@ -9554,6 +9572,7 @@ export {
isHiddenForCurrentUser,
prepareOnboardingOnyxData,
getReportSubtitlePrefix,
getExpenseReportStateAndStatus,
};

export type {
Expand All @@ -9570,4 +9589,5 @@ export type {
PartialReportAction,
ParsingDetails,
MissingPaymentMethod,
OptimisticNewReport,
};
Loading