Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
acd0828
Create Time Tracking settings page
mhawryluk Jan 23, 2026
561e200
Fix import
mhawryluk Jan 23, 2026
60eeb90
Fix new workspace page components
mhawryluk Jan 23, 2026
a712c89
Merge branch 'main' into time-tracking-settings-page
mhawryluk Jan 26, 2026
12538a9
Add navigation from more features to the new time page + refactor sty…
mhawryluk Jan 26, 2026
67a0428
Block unauthorized access to WorkspaceTimeTrackingPage
mhawryluk Jan 27, 2026
7b93dfa
Replace goBack with dismissModal in WorkspaceTimeTrackingRatePage
mhawryluk Jan 27, 2026
0c99ebf
Merge branch 'main' into time-tracking-settings-page
mhawryluk Jan 27, 2026
cc60170
Add translations
mhawryluk Jan 27, 2026
c45e2c6
Fix spanish translations
mhawryluk Jan 27, 2026
afd0dc1
Fix command's name, add pending field
mhawryluk Jan 27, 2026
3a92622
Remove addBottomSafeAreaPadding in WorkspaceTimeTrackingRatePage form
mhawryluk Jan 27, 2026
92e0d9e
Rename RATE to DEFAULT_RATE in time tracking components
mhawryluk Jan 28, 2026
6d953c7
Implement review suggestions
mhawryluk Jan 28, 2026
fa13cb9
Change copy for Time Tracking feature subtitle
mhawryluk Jan 28, 2026
f3324bf
Fix after merge
mhawryluk Jan 28, 2026
b2b1c94
Merge branch 'main' into time-tracking-settings-page
mhawryluk Jan 28, 2026
1b1b5ae
Fix after merge 2
mhawryluk Jan 28, 2026
892ba38
Check for loading onyx value in WorkspaceTimeTrackingDefaultRatePage
mhawryluk Jan 29, 2026
aec6e76
Merge branch 'main' into time-tracking-settings-page
mhawryluk Jan 29, 2026
3c02538
Fix offline indicator jumping on dismiss keyboard on mweb safari
mhawryluk Jan 29, 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
3 changes: 3 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,8 @@ const ONYXKEYS = {
WORKSPACE_INVOICES_COMPANY_NAME_FORM_DRAFT: 'workspaceInvoicesCompanyNameFormDraft',
WORKSPACE_INVOICES_COMPANY_WEBSITE_FORM: 'workspaceInvoicesCompanyWebsiteForm',
WORKSPACE_INVOICES_COMPANY_WEBSITE_FORM_DRAFT: 'workspaceInvoicesCompanyWebsiteFormDraft',
WORKSPACE_TIME_TRACKING_DEFAULT_RATE_FORM: 'workspaceTimeTrackingDefaultRateForm',
WORKSPACE_TIME_TRACKING_DEFAULT_RATE_FORM_DRAFT: 'workspaceTimeTrackingDefaultRateFormDraft',
NEW_CHAT_NAME_FORM: 'newChatNameForm',
NEW_CHAT_NAME_FORM_DRAFT: 'newChatNameFormDraft',
SUBSCRIPTION_SIZE_FORM: 'subscriptionSizeForm',
Expand Down Expand Up @@ -1070,6 +1072,7 @@ type OnyxFormValuesMapping = {
[ONYXKEYS.FORMS.WORKSPACE_TAX_VALUE_FORM]: FormTypes.WorkspaceTaxValueForm;
[ONYXKEYS.FORMS.WORKSPACE_INVOICES_COMPANY_NAME_FORM]: FormTypes.WorkspaceInvoicesCompanyNameForm;
[ONYXKEYS.FORMS.WORKSPACE_INVOICES_COMPANY_WEBSITE_FORM]: FormTypes.WorkspaceInvoicesCompanyWebsiteForm;
[ONYXKEYS.FORMS.WORKSPACE_TIME_TRACKING_DEFAULT_RATE_FORM]: FormTypes.WorkspaceTimeTrackingDefaultRateForm;
[ONYXKEYS.FORMS.NEW_CHAT_NAME_FORM]: FormTypes.NewChatNameForm;
[ONYXKEYS.FORMS.SUBSCRIPTION_SIZE_FORM]: FormTypes.SubscriptionSizeForm;
[ONYXKEYS.FORMS.ISSUE_NEW_EXPENSIFY_CARD_FORM]: FormTypes.IssueNewExpensifyCardForm;
Expand Down
15 changes: 15 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2624,6 +2624,21 @@ const ROUTES = {
route: 'workspaces/:policyID/per-diem/edit/currency/:rateID/:subRateID',
getRoute: (policyID: string, rateID: string, subRateID: string) => `workspaces/${policyID}/per-diem/edit/currency/${rateID}/${subRateID}` as const,
},

WORKSPACE_TIME_TRACKING: {
route: 'workspaces/:policyID/time-tracking',
getRoute: (policyID: string | undefined) => {
if (!policyID) {
Log.warn('Invalid policyID is used to build the WORKSPACE_TIME_TRACKING route');
}
return `workspaces/${policyID}/time-tracking` as const;
},
},
WORKSPACE_TIME_TRACKING_DEFAULT_RATE: {
route: 'workspaces/:policyID/time-tracking/rate',
getRoute: (policyID: string) => `workspaces/${policyID}/time-tracking/rate` as const,
},

REPORTS_DEFAULT_TITLE: {
route: 'workspaces/:policyID/reports/name',
getRoute: (policyID: string) => `workspaces/${policyID}/reports/name` as const,
Expand Down
2 changes: 2 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,8 @@ const SCREENS = {
PER_DIEM_EDIT_SUBRATE: 'Per_Diem_Edit_Subrate',
PER_DIEM_EDIT_AMOUNT: 'Per_Diem_Edit_Amount',
PER_DIEM_EDIT_CURRENCY: 'Per_Diem_Edit_Currency',
TIME_TRACKING: 'Time_Tracking',
TIME_TRACKING_DEFAULT_RATE: 'Time_Tracking_Default_Rate',
},

EDIT_REQUEST: {
Expand Down
1 change: 1 addition & 0 deletions src/components/FocusTrap/WIDE_LAYOUT_INACTIVE_SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const WIDE_LAYOUT_INACTIVE_SCREENS: string[] = [
SCREENS.WORKSPACE.RULES,
SCREENS.WORKSPACE.PER_DIEM,
SCREENS.WORKSPACE.RECEIPT_PARTNERS,
SCREENS.WORKSPACE.TIME_TRACKING,
];

export default WIDE_LAYOUT_INACTIVE_SCREENS;
6 changes: 5 additions & 1 deletion src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5304,7 +5304,11 @@ _Für ausführlichere Anweisungen [besuchen Sie unsere Hilfeseite](${CONST.NETSU
title: 'Regeln',
subtitle: 'Belege verlangen, hohe Ausgaben kennzeichnen und mehr.',
},
timeTracking: {title: 'Zeit', subtitle: 'Legen Sie einen abrechenbaren Stundensatz fest, damit Mitarbeitende für ihre Zeit bezahlt werden.'},
timeTracking: {
title: 'Zeit',
subtitle: 'Legen Sie einen abrechenbaren Stundensatz für die Zeiterfassung fest.',
defaultHourlyRate: 'Standardstundensatz',
},
},
reports: {
reportsCustomTitleExamples: 'Beispiele:',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5226,7 +5226,8 @@ const translations = {
},
timeTracking: {
title: 'Time',
subtitle: 'Set an hourly billable rate for employees to get paid for their time.',
subtitle: 'Set a billable hourly rate for time tracking.',
defaultHourlyRate: 'Default hourly rate',
},
},
reports: {
Expand Down
3 changes: 2 additions & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4981,7 +4981,8 @@ ${amount} para ${merchant} - ${date}`,
},
timeTracking: {
title: 'Tiempo',
subtitle: 'Establece una tarifa facturable por hora para que los empleados reciban pago por su tiempo.',
subtitle: 'Establecer una tarifa por hora facturable para el seguimiento de tiempo.',
defaultHourlyRate: 'Tarifa por hora predeterminada',
},
},
reports: {
Expand Down
6 changes: 5 additions & 1 deletion src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5313,7 +5313,11 @@ _Pour des instructions plus détaillées, [visitez notre site d’aide](${CONST.
title: 'Règles',
subtitle: 'Exigez des reçus, signalez les dépenses élevées, et plus encore.',
},
timeTracking: {title: 'Heure', subtitle: 'Définissez un taux horaire facturable pour que les employés soient rémunérés pour leur temps.'},
timeTracking: {
title: 'Heure',
subtitle: 'Définissez un taux horaire facturable pour le suivi du temps.',
defaultHourlyRate: 'Taux horaire par défaut',
},
},
reports: {
reportsCustomTitleExamples: 'Exemples :',
Expand Down
6 changes: 5 additions & 1 deletion src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5290,7 +5290,11 @@ _Per istruzioni più dettagliate, [visita il nostro sito di assistenza](${CONST.
title: 'Regole',
subtitle: 'Richiedi ricevute, segnala spese elevate e altro ancora.',
},
timeTracking: {title: 'Ora', subtitle: 'Imposta una tariffa oraria fatturabile per consentire ai dipendenti di essere pagati per il loro tempo.'},
timeTracking: {
title: 'Ora',
subtitle: 'Imposta una tariffa oraria fatturabile per il monitoraggio del tempo.',
defaultHourlyRate: 'Tariffa oraria predefinita',
},
},
reports: {
reportsCustomTitleExamples: 'Esempi:',
Expand Down
6 changes: 5 additions & 1 deletion src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5254,7 +5254,11 @@ _より詳しい手順については、[ヘルプサイトをご覧ください
title: 'ルール',
subtitle: 'レシートの必須化や高額支出のフラグ付けなどを設定できます。',
},
timeTracking: {title: '時間', subtitle: '従業員が作業時間に対して支払いを受けられるよう、時間単位の請求レートを設定します。'},
timeTracking: {
title: '時間',
subtitle: 'タイムトラッキング用の時間単価請求レートを設定します。',
defaultHourlyRate: 'デフォルトの時間単価',
},
},
reports: {
reportsCustomTitleExamples: '例:',
Expand Down
6 changes: 5 additions & 1 deletion src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5280,7 +5280,11 @@ _Voor gedetailleerdere instructies, [bezoek onze helpsite](${CONST.NETSUITE_IMPO
title: 'Regels',
subtitle: 'Vereis bonnetjes, markeer hoge uitgaven en meer.',
},
timeTracking: {title: 'Tijd', subtitle: 'Stel een uurtarief in waarmee medewerkers worden betaald voor hun tijd.'},
timeTracking: {
title: 'Tijd',
subtitle: 'Stel een factureerbaar uurtarief in voor tijdregistratie.',
defaultHourlyRate: 'Standaard uurtarief',
},
},
reports: {
reportsCustomTitleExamples: 'Voorbeelden:',
Expand Down
6 changes: 5 additions & 1 deletion src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5272,7 +5272,11 @@ _Aby uzyskać bardziej szczegółowe instrukcje, [odwiedź naszą stronę pomocy
title: 'Zasady',
subtitle: 'Wymagaj paragonów, oznaczaj wysokie wydatki i nie tylko.',
},
timeTracking: {title: 'Czas', subtitle: 'Ustaw godzinową stawkę rozliczeniową, aby pracownicy byli wynagradzani za swój czas.'},
timeTracking: {
title: 'Czas',
subtitle: 'Ustaw godzinową stawkę rozliczeniową do śledzenia czasu.',
defaultHourlyRate: 'Domyślna stawka godzinowa',
},
},
reports: {
reportsCustomTitleExamples: 'Przykłady:',
Expand Down
6 changes: 5 additions & 1 deletion src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5271,7 +5271,11 @@ _Para instruções mais detalhadas, [visite nosso site de ajuda](${CONST.NETSUIT
title: 'Regras',
subtitle: 'Exigir recibos, sinalizar gastos elevados e muito mais.',
},
timeTracking: {title: 'Hora', subtitle: 'Defina uma taxa horária faturável para que os funcionários sejam pagos pelo tempo trabalhado.'},
timeTracking: {
title: 'Hora',
subtitle: 'Defina uma taxa horária faturável para o controle de tempo.',
defaultHourlyRate: 'Taxa horária padrão',
},
},
reports: {
reportsCustomTitleExamples: 'Exemplos:',
Expand Down
6 changes: 5 additions & 1 deletion src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5164,7 +5164,11 @@ _如需更详细的说明,请[访问我们的帮助网站](${CONST.NETSUITE_IM
title: '规则',
subtitle: '要求收据、标记高额支出等。',
},
timeTracking: {title: '时间', subtitle: '为员工设置按小时计费的费率,以便根据他们的工作时间获得报酬。'},
timeTracking: {
title: '时间',
subtitle: '为时间跟踪设置按小时计费费率。',
defaultHourlyRate: '默认时薪',
},
},
reports: {
reportsCustomTitleExamples: '示例:',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type SetPolicyTimeTrackingDefaultRateParams = {
policyID: string;

/** Default hourly rate in policy's currency units (not subunits). */
defaultRate: number;
};

export default SetPolicyTimeTrackingDefaultRateParams;
1 change: 1 addition & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,3 +471,4 @@ export type {default as SetPolicyCodingRuleParams} from './SetPolicyCodingRulePa
export type {default as RegisterAuthenticationKeyParams} from './RegisterAuthenticationKeyParams';
export type {default as TroubleshootMultifactorAuthenticationParams} from './TroubleshootMultifactorAuthenticationParams';
export type {default as RequestAuthenticationChallengeParams} from './RequestAuthenticationChallengeParams';
export type {default as SetPolicyTimeTrackingDefaultRateParams} from './SetPolicyTimeTrackingDefaultRateParams';
2 changes: 2 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ const WRITE_COMMANDS = {
ENABLE_POLICY_COMPANY_CARDS: 'EnablePolicyCompanyCards',
ENABLE_POLICY_INVOICING: 'EnablePolicyInvoicing',
ENABLE_POLICY_TIME_TRACKING: 'EnablePolicyTimeTracking',
SET_POLICY_TIME_TRACKING_DEFAULT_RATE: 'SetPolicyTimeTrackingDefaultRate',
SET_POLICY_RULES_ENABLED: 'SetPolicyRulesEnabled',
SET_POLICY_CODING_RULE: 'SetPolicyCodingRule',
SET_POLICY_EXPENSE_MAX_AMOUNT_NO_RECEIPT: 'SetPolicyExpenseMaxAmountNoReceipt',
Expand Down Expand Up @@ -892,6 +893,7 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.UPDATE_DISTANCE_TAX_CLAIMABLE_VALUE]: Parameters.UpdatePolicyDistanceRateValueParams;
[WRITE_COMMANDS.SET_POLICY_DISTANCE_RATES_ENABLED]: Parameters.SetPolicyDistanceRatesEnabledParams;
[WRITE_COMMANDS.DELETE_POLICY_DISTANCE_RATES]: Parameters.DeletePolicyDistanceRatesParams;
[WRITE_COMMANDS.SET_POLICY_TIME_TRACKING_DEFAULT_RATE]: Parameters.SetPolicyTimeTrackingDefaultRateParams;
[WRITE_COMMANDS.DISMISS_TRACK_EXPENSE_ACTIONABLE_WHISPER]: Parameters.DismissTrackExpenseActionableWhisperParams;
[WRITE_COMMANDS.UPDATE_BILLING_CARD_CURRENCY]: Parameters.UpdateBillingCurrencyParams;
[WRITE_COMMANDS.CONVERT_TRACKED_EXPENSE_TO_REQUEST]: Parameters.ConvertTrackedExpenseToRequestParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
[SCREENS.WORKSPACE.RECEIPT_PARTNERS_INVITE]: () => require<ReactComponentModule>('../../../../pages/workspace/receiptPartners/InviteReceiptPartnerPolicyPage').default,
[SCREENS.WORKSPACE.RECEIPT_PARTNERS_INVITE_EDIT]: () => require<ReactComponentModule>('../../../../pages/workspace/receiptPartners/EditInviteReceiptPartnerPolicyPage').default,
[SCREENS.WORKSPACE.RECEIPT_PARTNERS_CHANGE_BILLING_ACCOUNT]: () => require<ReactComponentModule>('../../../../pages/workspace/receiptPartners/ChangeReceiptBillingAccountPage').default,
[SCREENS.WORKSPACE.TIME_TRACKING_DEFAULT_RATE]: () => require<ReactComponentModule>('../../../../pages/workspace/timeTracking/WorkspaceTimeTrackingDefaultRatePage').default,
[SCREENS.DOMAIN.VERIFY]: () => require<ReactComponentModule>('../../../../pages/domain/SamlVerifyDomainPage').default,
[SCREENS.DOMAIN.VERIFIED]: () => require<ReactComponentModule>('../../../../pages/domain/SamlDomainVerifiedPage').default,
[SCREENS.DOMAIN.ADMIN_DETAILS]: () => require<ReactComponentModule>('../../../../pages/domain/Admins/DomainAdminDetailsPage').default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const CENTRAL_PANE_WORKSPACE_SCREENS = {
[SCREENS.WORKSPACE.DISTANCE_RATES]: () => require<ReactComponentModule>('../../../../pages/workspace/distanceRates/PolicyDistanceRatesPage').default,
[SCREENS.WORKSPACE.TRAVEL]: () => require<ReactComponentModule>('../../../../pages/workspace/travel/PolicyTravelPage').default,
[SCREENS.WORKSPACE.RULES]: () => require<ReactComponentModule>('../../../../pages/workspace/rules/PolicyRulesPage').default,
[SCREENS.WORKSPACE.TIME_TRACKING]: () => require<ReactComponentModule>('../../../../pages/workspace/timeTracking/WorkspaceTimeTrackingPage').default,
} satisfies Screens;

const Split = createSplitNavigator<WorkspaceSplitNavigatorParamList>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ const WORKSPACE_TO_RHP: Partial<Record<keyof WorkspaceSplitNavigatorParamList, s
SCREENS.WORKSPACE.PER_DIEM_EDIT_AMOUNT,
SCREENS.WORKSPACE.PER_DIEM_EDIT_CURRENCY,
],
[SCREENS.WORKSPACE.TIME_TRACKING]: [SCREENS.WORKSPACE.TIME_TRACKING_DEFAULT_RATE],
[SCREENS.WORKSPACE.MORE_FEATURES]: [],
};

Expand Down
6 changes: 6 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,9 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
[SCREENS.WORKSPACE.PER_DIEM_EDIT_CURRENCY]: {
path: ROUTES.WORKSPACE_PER_DIEM_EDIT_CURRENCY.route,
},
[SCREENS.WORKSPACE.TIME_TRACKING_DEFAULT_RATE]: {
path: ROUTES.WORKSPACE_TIME_TRACKING_DEFAULT_RATE.route,
},
[SCREENS.DOMAIN.VERIFY]: {
path: ROUTES.DOMAIN_VERIFY.route,
},
Expand Down Expand Up @@ -2108,6 +2111,9 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
[SCREENS.WORKSPACE.RULES]: {
path: ROUTES.WORKSPACE_RULES.route,
},
[SCREENS.WORKSPACE.TIME_TRACKING]: {
path: ROUTES.WORKSPACE_TIME_TRACKING.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 @@ -1471,6 +1471,9 @@ type SettingsNavigatorParamList = {
rateID: string;
subRateID: string;
};
[SCREENS.WORKSPACE.TIME_TRACKING_DEFAULT_RATE]: {
policyID: string;
};
[SCREENS.DOMAIN.VERIFY]: {
domainAccountID: number;
};
Expand Down Expand Up @@ -2640,6 +2643,9 @@ type WorkspaceSplitNavigatorParamList = {
[SCREENS.WORKSPACE.RULES]: {
policyID: string;
};
[SCREENS.WORKSPACE.TIME_TRACKING]: {
policyID: string;
};
};

type DomainSplitNavigatorParamList = {
Expand Down
4 changes: 2 additions & 2 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

let allPolicies: OnyxCollection<Policy>;

Onyx.connect({

Check warning on line 63 in src/libs/PolicyUtils.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 @@ -1779,8 +1779,8 @@
return !!policy?.units?.time?.enabled;
}

function getDefaultTimeTrackingRate(policy: Policy): number | undefined {
return policy.units?.time?.rate ? convertToBackendAmount(policy.units?.time?.rate) : undefined;
function getDefaultTimeTrackingRate(policy: Partial<OnyxEntry<Policy>>): number | undefined {
return policy?.units?.time?.rate ? convertToBackendAmount(policy.units.time.rate) : undefined;
}

export {
Expand Down
39 changes: 39 additions & 0 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
};

const deprecatedAllPolicies: OnyxCollection<Policy> = {};
Onyx.connect({

Check warning on line 223 in src/libs/actions/Policy/Policy.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,
callback: (val, key) => {
if (!key) {
Expand All @@ -236,7 +236,7 @@
});

let deprecatedAllReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 239 in src/libs/actions/Policy/Policy.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_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand All @@ -246,7 +246,7 @@

let deprecatedSessionEmail = '';
let deprecatedSessionAccountID = 0;
Onyx.connect({

Check warning on line 249 in src/libs/actions/Policy/Policy.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: (val) => {
deprecatedSessionEmail = val?.email ?? '';
Expand All @@ -255,7 +255,7 @@
});

let deprecatedAllPersonalDetails: OnyxEntry<PersonalDetailsList>;
Onyx.connect({

Check warning on line 258 in src/libs/actions/Policy/Policy.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: (val) => (deprecatedAllPersonalDetails = val),
});
Expand Down Expand Up @@ -4809,6 +4809,44 @@
}
}

/**
* Update policy's time tracking default hourly rate.
* The rate should be passed in currency units, not subunits.
*/
function setPolicyTimeTrackingDefaultRate(policyID: string, rate: number) {
const onyxData: OnyxData<typeof ONYXKEYS.COLLECTION.POLICY> = {
optimisticData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
units: {
time: {
rate,
},
},
pendingFields: {
timeTrackingDefaultRate: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
},
},
],
finallyData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
pendingFields: {
timeTrackingDefaultRate: null,
},
},
},
],
};

API.write(WRITE_COMMANDS.SET_POLICY_TIME_TRACKING_DEFAULT_RATE, {policyID, defaultRate: rate}, onyxData);
}

function openPolicyMoreFeaturesPage(policyID: string) {
const params: OpenPolicyMoreFeaturesPageParams = {policyID};

Expand Down Expand Up @@ -6892,4 +6930,5 @@
inviteWorkspaceEmployeesToUber,
setWorkspaceConfirmationCurrency,
setPolicyRequireCompanyCardsEnabled,
setPolicyTimeTrackingDefaultRate,
};
2 changes: 1 addition & 1 deletion src/pages/iou/request/step/IOURequestStepHours.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function IOURequestStepHours({
const {accountID} = useCurrentUserPersonalDetails();
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {canBeMissing: true});
const currency = policy?.outputCurrency ?? CONST.CURRENCY.USD;
const defaultPolicyRate = policy ? getDefaultTimeTrackingRate(policy) : undefined;
const defaultPolicyRate = getDefaultTimeTrackingRate(policy);
const rate = transaction?.comment?.units?.rate ?? defaultPolicyRate;

const {translate} = useLocalize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function IOURequestStepTimeWorkspace({route, navigation}: IOURequestStepTimeWork
setTransactionReport(transactionID, {reportID: policyExpenseChat.reportID}, isTransactionDraft);
setMoneyRequestParticipantsFromReport(transactionID, policyExpenseChat, accountID);

const defaultRate = policy ? getDefaultTimeTrackingRate(policy) : undefined;
const defaultRate = getDefaultTimeTrackingRate(policy);
if (defaultRate) {
setMoneyRequestTimeRate(transactionID, defaultRate, isTransactionDraft);
}
Expand Down
Loading
Loading