Skip to content
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
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,7 @@ const CONST = {
REQUEST_MANUAL: 'requestManual',
REQUEST_SCAN: 'requestScan',
REQUEST_DISTANCE: 'requestDistance',
REQUEST_TIME: 'requestTime',
PER_DIEM: 'perDiem',
SPLIT_MANUAL: 'splitManual',
SPLIT_SCAN: 'splitScan',
Expand Down
1 change: 1 addition & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,7 @@ const translations: TranslationDeepObject<typeof en> = {
noLongerHaveReportAccess: 'Sie haben keinen Zugriff mehr auf Ihr bisheriges Ziel für Schnellaktionen. Wählen Sie unten ein neues aus.',
updateDestination: 'Ziel aktualisieren',
createReport: 'Bericht erstellen',
createTimeExpense: 'Zeitaufwand erstellen',
},
iou: {
amount: 'Betrag',
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,7 @@ const translations = {
noLongerHaveReportAccess: 'You no longer have access to your previous quick action destination. Pick a new one below.',
updateDestination: 'Update destination',
createReport: 'Create report',
createTimeExpense: 'Create time expense',
},
iou: {
amount: 'Amount',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ const translations: TranslationDeepObject<typeof en> = {
noLongerHaveReportAccess: 'Ya no tienes acceso al destino previo de esta acción rápida. Escoge uno nuevo a continuación.',
updateDestination: 'Actualiza el destino',
createReport: 'Crear informe',
createTimeExpense: 'Crear gasto de tiempo',
},
iou: {
amount: 'Importe',
Expand Down
1 change: 1 addition & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ const translations: TranslationDeepObject<typeof en> = {
noLongerHaveReportAccess: 'Vous n’avez plus accès à votre précédente destination d’action rapide. Choisissez-en une nouvelle ci-dessous.',
updateDestination: 'Mettre à jour la destination',
createReport: 'Créer une note de frais',
createTimeExpense: 'Créer une dépense de temps',
},
iou: {
amount: 'Montant',
Expand Down
1 change: 1 addition & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,7 @@ const translations: TranslationDeepObject<typeof en> = {
noLongerHaveReportAccess: 'Non hai più accesso alla precedente destinazione dell’azione rapida. Selezionane una nuova qui sotto.',
updateDestination: 'Aggiorna destinazione',
createReport: 'Crea resoconto',
createTimeExpense: 'Crea nota spese tempo',
},
iou: {
amount: 'Importo',
Expand Down
1 change: 1 addition & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,7 @@ const translations: TranslationDeepObject<typeof en> = {
noLongerHaveReportAccess: '以前のクイック操作の宛先にはアクセスできなくなりました。下から新しい宛先を選択してください。',
updateDestination: '送信先を更新',
createReport: 'レポートを作成',
createTimeExpense: '時間経費を作成',
},
iou: {
amount: '金額',
Expand Down
1 change: 1 addition & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,7 @@ const translations: TranslationDeepObject<typeof en> = {
noLongerHaveReportAccess: 'Je hebt geen toegang meer tot je vorige snelkoppelingsbestemming. Kies hieronder een nieuwe.',
updateDestination: 'Bestemming bijwerken',
createReport: 'Rapport maken',
createTimeExpense: 'Tijdkosten aanmaken',
},
iou: {
amount: 'Bedrag',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,7 @@ const translations: TranslationDeepObject<typeof en> = {
noLongerHaveReportAccess: 'Nie masz już dostępu do swojego poprzedniego szybkiego działania. Wybierz poniżej nowe.',
updateDestination: 'Zaktualizuj miejsce docelowe',
createReport: 'Utwórz raport',
createTimeExpense: 'Utwórz wydatek czasowy',
},
iou: {
amount: 'Kwota',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,7 @@ const translations: TranslationDeepObject<typeof en> = {
noLongerHaveReportAccess: 'Você não tem mais acesso ao seu destino anterior de ação rápida. Escolha um novo abaixo.',
updateDestination: 'Atualizar destino',
createReport: 'Criar relatório',
createTimeExpense: 'Criar despesa de tempo',
},
iou: {
amount: 'Valor',
Expand Down
1 change: 1 addition & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,7 @@ const translations: TranslationDeepObject<typeof en> = {
noLongerHaveReportAccess: '您已无法访问之前的快捷操作目标。请在下方选择一个新的目标。',
updateDestination: '更新目的地',
createReport: '创建报表',
createTimeExpense: '创建工时报销',
},
iou: {
amount: '金额',
Expand Down
15 changes: 13 additions & 2 deletions src/libs/QuickActionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import type QuickAction from '@src/types/onyx/QuickAction';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import type IconAsset from '@src/types/utils/IconAsset';
import getIconForAction from './getIconForAction';
import {getPerDiemCustomUnit} from './PolicyUtils';
import {getPerDiemCustomUnit, isTimeTrackingEnabled} from './PolicyUtils';
import {canCreateRequest} from './ReportUtils';

const getQuickActionIcon = (
icons: Record<'CalendarSolid' | 'Car' | 'Task' | 'Coins' | 'Receipt' | 'Cash' | 'Transfer' | 'ReceiptScan' | 'MoneyCircle', IconAsset>,
icons: Record<'CalendarSolid' | 'Car' | 'Task' | 'Coins' | 'Receipt' | 'Cash' | 'Transfer' | 'ReceiptScan' | 'MoneyCircle' | 'Clock', IconAsset>,
action: QuickActionName,
): IconAsset => {
switch (action) {
Expand All @@ -37,6 +37,8 @@ const getQuickActionIcon = (
return getIconForAction(CONST.IOU.TYPE.TRACK, icons);
case CONST.QUICK_ACTIONS.TRACK_SCAN:
return icons.ReceiptScan;
case CONST.QUICK_ACTIONS.REQUEST_TIME:
return icons.Clock;
default:
return icons.MoneyCircle;
}
Expand All @@ -47,6 +49,7 @@ const getIOUType = (action: QuickActionName | undefined) => {
case CONST.QUICK_ACTIONS.REQUEST_MANUAL:
case CONST.QUICK_ACTIONS.REQUEST_SCAN:
case CONST.QUICK_ACTIONS.REQUEST_DISTANCE:
case CONST.QUICK_ACTIONS.REQUEST_TIME:
case CONST.QUICK_ACTIONS.PER_DIEM:
return CONST.IOU.TYPE.SUBMIT;
case CONST.QUICK_ACTIONS.SPLIT_MANUAL:
Expand Down Expand Up @@ -88,6 +91,8 @@ const getQuickActionTitle = (action: QuickActionName): TranslationPaths => {
return 'quickAction.paySomeone';
case CONST.QUICK_ACTIONS.ASSIGN_TASK:
return 'quickAction.assignTask';
case CONST.QUICK_ACTIONS.REQUEST_TIME:
return 'quickAction.createTimeExpense';
default:
return '' as TranslationPaths;
}
Expand All @@ -112,6 +117,12 @@ const isQuickActionAllowed = (
return false;
}
}
if (quickAction?.action === CONST.QUICK_ACTIONS.REQUEST_TIME) {
if (!isTimeTrackingEnabled(quickActionPolicy)) {
return false;
}
}

const iouType = getIOUType(quickAction?.action);
if (iouType) {
// We're disabling QAB for Manager McTest reports to prevent confusion when submitting real data for Manager McTest
Expand Down
4 changes: 4 additions & 0 deletions src/libs/actions/IOU/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
isPerDiemRequest as isPerDiemRequestTransactionUtils,
isScanning,
isScanRequest as isScanRequestTransactionUtils,
isTimeRequest as isTimeRequestTransactionUtils,
removeTransactionFromDuplicateTransactionViolation,
} from '@libs/TransactionUtils';
import ViolationsUtils from '@libs/Violations/ViolationsUtils';
Expand Down Expand Up @@ -791,7 +792,7 @@
};

let allPersonalDetails: OnyxTypes.PersonalDetailsList = {};
Onyx.connect({

Check warning on line 795 in src/libs/actions/IOU/index.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: (value) => {
allPersonalDetails = value ?? {};
Expand Down Expand Up @@ -884,7 +885,7 @@
};

let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 888 in src/libs/actions/IOU/index.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.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -898,7 +899,7 @@
});

let allTransactionDrafts: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 902 in src/libs/actions/IOU/index.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.TRANSACTION_DRAFT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -907,7 +908,7 @@
});

let allTransactionViolations: NonNullable<OnyxCollection<OnyxTypes.TransactionViolations>> = {};
Onyx.connect({

Check warning on line 911 in src/libs/actions/IOU/index.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.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -921,7 +922,7 @@
});

let allPolicyTags: OnyxCollection<OnyxTypes.PolicyTagLists> = {};
Onyx.connect({

Check warning on line 925 in src/libs/actions/IOU/index.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_TAGS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -934,7 +935,7 @@
});

let allReports: OnyxCollection<OnyxTypes.Report>;
Onyx.connect({

Check warning on line 938 in src/libs/actions/IOU/index.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,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -943,7 +944,7 @@
});

let allReportNameValuePairs: OnyxCollection<OnyxTypes.ReportNameValuePairs>;
Onyx.connect({

Check warning on line 947 in src/libs/actions/IOU/index.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_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -953,7 +954,7 @@

let userAccountID = -1;
let currentUserEmail = '';
Onyx.connect({

Check warning on line 957 in src/libs/actions/IOU/index.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: (value) => {
currentUserEmail = value?.email ?? '';
Expand All @@ -962,7 +963,7 @@
});

let deprecatedCurrentUserPersonalDetails: OnyxEntry<OnyxTypes.PersonalDetails>;
Onyx.connect({

Check warning on line 966 in src/libs/actions/IOU/index.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: (value) => {
deprecatedCurrentUserPersonalDetails = value?.[userAccountID] ?? undefined;
Expand All @@ -970,7 +971,7 @@
});

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

Check warning on line 974 in src/libs/actions/IOU/index.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 Down Expand Up @@ -1938,6 +1939,7 @@

const isScanRequest = isScanRequestTransactionUtils(transaction);
const isPerDiemRequest = isPerDiemRequestTransactionUtils(transaction);
const isTimeRequest = isTimeRequestTransactionUtils(transaction);
const outstandingChildRequest = getOutstandingChildRequest(iou.report);
const clearedPendingFields = Object.fromEntries(Object.keys(transaction.pendingFields ?? {}).map((key) => [key, null]));
const isMoneyRequestToManagerMcTest = isTestTransactionReport(iou.report);
Expand All @@ -1953,6 +1955,8 @@
newQuickAction = CONST.QUICK_ACTIONS.REQUEST_SCAN;
} else if (isPerDiemRequest) {
newQuickAction = CONST.QUICK_ACTIONS.PER_DIEM;
} else if (isTimeRequest) {
newQuickAction = CONST.QUICK_ACTIONS.REQUEST_TIME;
} else {
newQuickAction = CONST.QUICK_ACTIONS.REQUEST_MANUAL;
}
Expand Down
5 changes: 5 additions & 0 deletions src/libs/actions/QuickActionNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ function getQuickActionRequestType(action: QuickActionName | undefined, lastDist
requestType = lastDistanceExpenseType ?? CONST.IOU.REQUEST_TYPE.DISTANCE_MAP;
} else if (action === CONST.QUICK_ACTIONS.PER_DIEM) {
requestType = CONST.IOU.REQUEST_TYPE.PER_DIEM;
} else if (action === CONST.QUICK_ACTIONS.REQUEST_TIME) {
requestType = CONST.IOU.REQUEST_TYPE.TIME;
}

return requestType;
Expand Down Expand Up @@ -70,6 +72,9 @@ function navigateToQuickAction(params: NavigateToQuickActionParams) {
case CONST.QUICK_ACTIONS.TRACK_DISTANCE:
selectOption(() => startDistanceRequest(CONST.IOU.TYPE.TRACK, reportID, requestType, true, undefined, isFromFloatingActionButton), false);
break;
case CONST.QUICK_ACTIONS.REQUEST_TIME:
selectOption(() => startMoneyRequest(CONST.IOU.TYPE.SUBMIT, reportID, requestType, false, undefined, undefined, isFromFloatingActionButton), true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we not allowing skipConfirmation for Time expenses? Was it intentional or is it a mistake?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was intentional. I believe we decided to not skip the confirmation page when creating time expenses from quick action.

break;
default:
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref
'Cash',
'Transfer',
'MoneyCircle',
'Clock',
] as const);
const styles = useThemeStyles();
const theme = useTheme();
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/QuickActionNavigationTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,22 @@ describe('IOU Utils', () => {
// Then we should start per diem request flow
expect(startMoneyRequest).toHaveBeenCalledWith(CONST.IOU.TYPE.SUBMIT, reportID, CONST.IOU.REQUEST_TYPE.PER_DIEM, true, undefined, undefined, undefined);
});

it('should be navigated to Time Expense', () => {
// When the quick action is REQUEST_TIME
navigateToQuickAction({
isValidReport: true,
quickAction: {action: CONST.QUICK_ACTIONS.REQUEST_TIME, chatReportID: reportID},
selectOption: (onSelected: () => void) => {
onSelected();
},
targetAccountPersonalDetails: createPersonalDetails(1),
currentUserAccountID: CONST.DEFAULT_NUMBER_ID,
});

// Then we should start time request flow
expect(startMoneyRequest).toHaveBeenCalledWith(CONST.IOU.TYPE.SUBMIT, reportID, CONST.IOU.REQUEST_TYPE.TIME, false, undefined, undefined, undefined);
});
});
});

Expand Down
45 changes: 45 additions & 0 deletions tests/unit/QuickActionUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,50 @@ describe('QuickActionUtils', () => {
expect(isQuickActionAllowed(perDiemAction, report, policy, false, false)).toBe(false);
});
});

describe('Policy with time tracking', () => {
it('should allow requestTime action when policy has time tracking enabled', () => {
Comment thread
mhawryluk marked this conversation as resolved.
Resolved
mockedPolicyUtils.isTimeTrackingEnabled.mockReturnValue(true);
expect(
isQuickActionAllowed(
{action: CONST.QUICK_ACTIONS.REQUEST_TIME},
{
reportID: '1',
isOwnPolicyExpenseChat: true,
type: CONST.REPORT.TYPE.EXPENSE,
policyID: '1',
ownerAccountID: 1,
},
{
id: '1',
units: {time: {enabled: true, rate: 1}},
} as Policy,
false,
false,
),
).toBe(true);
});

it('should not allow requestTime action when policy has time tracking disabled', () => {
mockedPolicyUtils.isTimeTrackingEnabled.mockReturnValue(false);
expect(
isQuickActionAllowed(
{action: CONST.QUICK_ACTIONS.REQUEST_TIME},
{
reportID: '1',
isOwnPolicyExpenseChat: true,
type: CONST.REPORT.TYPE.EXPENSE,
policyID: '1',
ownerAccountID: 1,
},
{
id: '1',
} as Policy,
false,
false,
),
).toBe(false);
});
});
});
});
Loading