Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
52338aa
added IOURequestStepAccountant
s77rt Mar 12, 2025
f513feb
added MoneyRequestAccountantSelector
s77rt Mar 13, 2025
169b9ee
pass accountant
s77rt Mar 13, 2025
15a779d
added s77rt comment
s77rt Mar 13, 2025
60231e7
added s77rt comment
s77rt Mar 13, 2025
4082cba
use accountant field
s77rt Mar 14, 2025
46fdac4
add accountant to ws as admin
s77rt Mar 15, 2025
a13ddc9
update accountant role to admin if already a member
s77rt Mar 15, 2025
53753a0
remove unnecessary empty line
s77rt Mar 15, 2025
7a9160e
added optimistic data for inviting the accountant into the expense re…
s77rt Mar 18, 2025
6b8e882
remove old accountant invitation logic
s77rt Mar 18, 2025
d56c3ba
translate
s77rt Mar 18, 2025
581f989
fix test
s77rt Mar 18, 2025
46806d2
lint
s77rt Mar 18, 2025
093dcff
fix test and debug utils lint
s77rt Mar 18, 2025
aaf06c5
pass chatReportID
s77rt Mar 18, 2025
2ac6e8a
lint
s77rt Mar 18, 2025
c99848a
exclude policies where you don't have admin access
s77rt Mar 19, 2025
364f2c8
merge main
s77rt Mar 19, 2025
42fc209
resolve a s77rt comment
s77rt Mar 19, 2025
5231b9d
pass accountantEmail correctly
s77rt Mar 20, 2025
41ae23c
added test
s77rt Mar 20, 2025
090bfe2
lint
s77rt Mar 20, 2025
f2e85bc
added s77rt comment
s77rt Mar 20, 2025
72bced4
added test for accountant that is already a member of the ws
s77rt Mar 20, 2025
6913704
merge main
s77rt Mar 21, 2025
be620ff
avoid passing duplicated params info
s77rt Mar 21, 2025
6592818
handle case were no admin workspace is available
s77rt Mar 22, 2025
ef695d1
merge main
s77rt Mar 24, 2025
916f304
merge main
s77rt Apr 18, 2025
d4323e0
merge main
s77rt Apr 18, 2025
42a9572
merge main
s77rt Apr 25, 2025
3fa717c
added useOnyx canBeMissing param
s77rt Apr 25, 2025
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
16 changes: 12 additions & 4 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,13 +561,12 @@ const ROUTES = {
getRoute: (reportID: string, accountID: number, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/members/${accountID}` as const, backTo),
},
ROOM_INVITE: {
route: 'r/:reportID/invite/:role?',
getRoute: (reportID: string | undefined, role?: string, backTo?: string) => {
route: 'r/:reportID/invite',
getRoute: (reportID: string | undefined, backTo?: string) => {
if (!reportID) {
Log.warn('Invalid reportID is used to build the ROOM_INVITE route');
}
const route = role ? (`r/${reportID}/invite/${role}` as const) : (`r/${reportID}/invite` as const);
return getUrlWithBackToParam(route, backTo);
return getUrlWithBackToParam(`r/${reportID}/invite` as const, backTo);
},
},
MONEY_REQUEST_HOLD_REASON: {
Expand Down Expand Up @@ -642,6 +641,15 @@ const ROUTES = {
return getUrlWithBackToParam(`${action as string}/${iouType as string}/attendees/${transactionID}/${reportID}`, backTo);
},
},
MONEY_REQUEST_ACCOUNTANT: {
route: ':action/:iouType/accountant/:transactionID/:reportID',
getRoute: (action: IOUAction, iouType: IOUType, transactionID: string | undefined, reportID: string | undefined, backTo = '') => {
if (!transactionID || !reportID) {
Log.warn('Invalid transactionID or reportID is used to build the MONEY_REQUEST_ACCOUNTANT route');
}
return getUrlWithBackToParam(`${action as string}/${iouType as string}/accountant/${transactionID}/${reportID}`, backTo);
},
},
MONEY_REQUEST_UPGRADE: {
route: ':action/:iouType/upgrade/:transactionID/:reportID',
getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, backTo = '') =>
Expand Down
1 change: 1 addition & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ const SCREENS = {
RECEIPT: 'Money_Request_Receipt',
STATE_SELECTOR: 'Money_Request_State_Selector',
STEP_ATTENDEES: 'Money_Request_Attendee',
STEP_ACCOUNTANT: 'Money_Request_Accountant',
STEP_DESTINATION: 'Money_Request_Destination',
STEP_TIME: 'Money_Request_Time',
STEP_SUBRATE: 'Money_Request_SubRate',
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,7 @@ const translations = {
bookingArchived: 'This booking is archived',
bookingArchivedDescription: 'This booking is archived because the trip date has passed. Add an expense for the final amount if needed.',
attendees: 'Attendees',
whoIsYourAccountant: 'Who is your accountant?',
paymentComplete: 'Payment complete',
time: 'Time',
startDate: 'Start date',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,7 @@ const translations = {
bookingArchived: 'Esta reserva está archivada',
bookingArchivedDescription: 'Esta reserva está archivada porque la fecha del viaje ha pasado. Agregue un gasto por el monto final si es necesario.',
attendees: 'Asistentes',
whoIsYourAccountant: '¿Quién es tu contador?',
paymentComplete: 'Pago completo',
time: 'Tiempo',
startDate: 'Fecha de inicio',
Expand Down
1 change: 1 addition & 0 deletions src/libs/API/parameters/ShareTrackedExpenseParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type ShareTrackedExpenseParams = {
engagementChoice?: string;
guidedSetupData?: string;
description?: string;
accountantEmail: string;
policyName?: string;
};

Expand Down
6 changes: 6 additions & 0 deletions src/libs/DebugUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,7 @@ function validateTransactionDraftProperty(key: keyof Transaction, value: string)
managedCard: CONST.RED_BRICK_ROAD_PENDING_ACTION,
posted: CONST.RED_BRICK_ROAD_PENDING_ACTION,
inserted: CONST.RED_BRICK_ROAD_PENDING_ACTION,
accountant: CONST.RED_BRICK_ROAD_PENDING_ACTION,
},
'string',
);
Expand Down Expand Up @@ -1089,6 +1090,11 @@ function validateTransactionDraftProperty(key: keyof Transaction, value: string)
splits: 'array',
dismissedViolations: 'object',
});
case 'accountant':
return validateObject<ObjectElement<Transaction, 'accountant'>>(value, {
accountID: 'number',
login: 'string',
});
case 'modifiedAttendees':
return validateArray<ArrayElement<Comment, 'attendees'>>(value, {
email: 'string',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ const MoneyRequestModalStackNavigator = createModalStackNavigator<MoneyRequestNa
[SCREENS.IOU_SEND.ENABLE_PAYMENTS]: () => require<ReactComponentModule>('../../../../pages/EnablePayments/EnablePaymentsPage').default,
[SCREENS.MONEY_REQUEST.STATE_SELECTOR]: () => require<ReactComponentModule>('../../../../pages/settings/Profile/PersonalDetails/StateSelectionPage').default,
[SCREENS.MONEY_REQUEST.STEP_ATTENDEES]: () => require<ReactComponentModule>('../../../../pages/iou/request/step/IOURequestStepAttendees').default,
[SCREENS.MONEY_REQUEST.STEP_ACCOUNTANT]: () => require<ReactComponentModule>('../../../../pages/iou/request/step/IOURequestStepAccountant').default,
[SCREENS.MONEY_REQUEST.STEP_UPGRADE]: () => require<ReactComponentModule>('../../../../pages/iou/request/step/IOURequestStepUpgrade').default,
[SCREENS.MONEY_REQUEST.STEP_DESTINATION]: () => require<ReactComponentModule>('../../../../pages/iou/request/step/IOURequestStepDestination').default,
[SCREENS.MONEY_REQUEST.STEP_TIME]: () => require<ReactComponentModule>('../../../../pages/iou/request/step/IOURequestStepTime').default,
Expand Down
1 change: 1 addition & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,7 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
},
[SCREENS.MONEY_REQUEST.STEP_SPLIT_PAYER]: ROUTES.MONEY_REQUEST_STEP_SPLIT_PAYER.route,
[SCREENS.MONEY_REQUEST.STEP_ATTENDEES]: ROUTES.MONEY_REQUEST_ATTENDEE.route,
[SCREENS.MONEY_REQUEST.STEP_ACCOUNTANT]: ROUTES.MONEY_REQUEST_ACCOUNTANT.route,
[SCREENS.MONEY_REQUEST.STEP_UPGRADE]: ROUTES.MONEY_REQUEST_UPGRADE.route,
[SCREENS.MONEY_REQUEST.STEP_DESTINATION]: ROUTES.MONEY_REQUEST_STEP_DESTINATION.route,
[SCREENS.MONEY_REQUEST.STEP_TIME]: ROUTES.MONEY_REQUEST_STEP_TIME.route,
Expand Down
7 changes: 7 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,13 @@ type MoneyRequestNavigatorParamList = {
reportID: string;
backTo: Routes;
};
[SCREENS.MONEY_REQUEST.STEP_ACCOUNTANT]: {
action: IOUAction;
iouType: Exclude<IOUType, typeof CONST.IOU.TYPE.REQUEST | typeof CONST.IOU.TYPE.SEND>;
transactionID: string;
reportID: string;
backTo: Routes;
};
[SCREENS.MONEY_REQUEST.STEP_UPGRADE]: {
action: IOUAction;
iouType: Exclude<IOUType, typeof CONST.IOU.TYPE.REQUEST | typeof CONST.IOU.TYPE.SEND>;
Expand Down
6 changes: 6 additions & 0 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ type GetValidReportsConfig = {
loginsToExclude?: Record<string, boolean>;
shouldSeparateWorkspaceChat?: boolean;
shouldSeparateSelfDMChat?: boolean;
excludeNonAdminWorkspaces?: boolean;
} & GetValidOptionsSharedConfig;

type GetValidReportsReturnTypeCombined = {
Expand Down Expand Up @@ -1402,6 +1403,7 @@ function getValidReports(reports: OptionList['reports'], config: GetValidReports
loginsToExclude = {},
shouldSeparateSelfDMChat,
shouldSeparateWorkspaceChat,
excludeNonAdminWorkspaces,
} = config;
const topmostReportId = Navigation.getTopmostReportId();

Expand Down Expand Up @@ -1441,6 +1443,10 @@ function getValidReports(reports: OptionList['reports'], config: GetValidReports
const isChatRoom = option.isChatRoom;
const accountIDs = getParticipantsAccountIDsForDisplay(report);

if (excludeNonAdminWorkspaces && !isPolicyAdmin(option.policyID, policies)) {
continue;
}

if (isPolicyExpenseChat && report.isOwnPolicyExpenseChat && !includeOwnedWorkspaceChats) {
continue;
}
Expand Down
8 changes: 8 additions & 0 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,13 @@ function getActiveAdminWorkspaces(policies: OnyxCollection<Policy> | null, curre
return activePolicies.filter((policy) => shouldShowPolicy(policy, isOfflineNetworkStore(), currentUserLogin) && isPolicyAdmin(policy, currentUserLogin));
}

/**
* Checks whether the current user has a policy with admin access
*/
function hasActiveAdminWorkspaces(currentUserLogin: string | undefined) {
return getActiveAdminWorkspaces(allPolicies, currentUserLogin).length > 0;
}

/**
*
* Checks whether the current user has a policy with Xero accounting software integration
Expand Down Expand Up @@ -1474,6 +1481,7 @@ export {
isTaxTrackingEnabled,
shouldShowPolicy,
getActiveAdminWorkspaces,
hasActiveAdminWorkspaces,
getOwnedPaidPolicies,
canSendInvoiceFromWorkspace,
canSubmitPerDiemExpenseFromWorkspace,
Expand Down
5 changes: 5 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9511,6 +9511,11 @@ function createDraftTransactionAndNavigateToParticipantSelector(
return;
}

if (actionName === CONST.IOU.ACTION.SHARE) {
Navigation.navigate(ROUTES.MONEY_REQUEST_ACCOUNTANT.getRoute(actionName, CONST.IOU.TYPE.SUBMIT, transactionID, reportID, undefined));
return;
}

if (actionName === CONST.IOU.ACTION.SUBMIT || (allPolicies && filteredPolicies.length > 0)) {
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.SUBMIT, transactionID, reportID, undefined, actionName));
return;
Expand Down
Loading