Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
d4e2954
Update SubmitReport API command
abzokhattab Nov 20, 2025
8b510f3
minor edit
abzokhattab Nov 20, 2025
3339448
minor fixes
abzokhattab Nov 20, 2025
838b360
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Nov 20, 2025
e7648c0
Add support for DEW submit with beta flag
abzokhattab Nov 20, 2025
2dbf516
keep the optimisitc value not changed on submit
abzokhattab Nov 21, 2025
99cbd17
cleaning unneeded comments
abzokhattab Nov 21, 2025
1efb016
reverting permissions change
abzokhattab Nov 21, 2025
e7c2d71
adding test cases
abzokhattab Nov 21, 2025
f9adf21
fixing missing translations
abzokhattab Nov 21, 2025
cdaf4ad
covering missing translations
abzokhattab Nov 21, 2025
a65eb6a
covering more tests
abzokhattab Nov 21, 2025
5ad6b37
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Nov 21, 2025
23ee824
fixing ts
abzokhattab Nov 21, 2025
8ba5fcf
fixing eslint
abzokhattab Nov 21, 2025
96338b9
minor edit
abzokhattab Nov 21, 2025
2bf0e96
fixing tests
abzokhattab Nov 21, 2025
338102b
Merge branch 'main' into dew-submit-report
abzokhattab Nov 21, 2025
62a0953
minor edit
abzokhattab Nov 21, 2025
1ae07ff
covering iou tests
abzokhattab Nov 21, 2025
b2f5a34
fixing tests
abzokhattab Nov 21, 2025
9f4e555
fixing es translation
abzokhattab Nov 21, 2025
ae04f76
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Nov 24, 2025
5201219
add isDEWBetaEnabled check in all other places that use the block DEW…
abzokhattab Nov 24, 2025
0ed1497
cleaning handleDEWModalOpen
abzokhattab Nov 24, 2025
8a3c570
minor: renaming isDEWBetaEnabled flag
abzokhattab Nov 24, 2025
bbbbc07
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Nov 24, 2025
dd6afc2
cleanup
abzokhattab Nov 25, 2025
f66c1d5
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Nov 25, 2025
a0f2dfa
cleaning the test
abzokhattab Nov 25, 2025
e3ddfde
removning approve related types
abzokhattab Nov 25, 2025
9315aec
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Nov 26, 2025
d599262
refactor finding the most recent DEW_SUBMIT_FAILED action
abzokhattab Nov 26, 2025
db03933
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Nov 26, 2025
23d5efa
fixing LHN queuedToSubmitViaDEW msg
abzokhattab Nov 26, 2025
f7da162
fixing ts errors
abzokhattab Nov 26, 2025
2c4e24b
Merge branch 'main' into dew-submit-report
abzokhattab Nov 29, 2025
109d734
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 2, 2025
7060a9f
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 2, 2025
305d520
changing action name to DEWSUBMITFAILED
abzokhattab Dec 2, 2025
62de524
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 2, 2025
ad7066a
fixing submit failed actions
abzokhattab Dec 2, 2025
351b28e
minor edit
abzokhattab Dec 2, 2025
c847cc3
adding generic fallback error to lastMessageTextFromReport
abzokhattab Dec 2, 2025
417834a
adding more test cases
abzokhattab Dec 2, 2025
ad62c48
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 2, 2025
aed96bd
Fixing tests
abzokhattab Dec 2, 2025
a22b3d6
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 2, 2025
76d1982
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 2, 2025
b930fa4
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 3, 2025
3d805ca
remvoe the unneeded hasDewError const
abzokhattab Dec 3, 2025
2cc03cc
making err as next step instead of next step status
abzokhattab Dec 3, 2025
c68ba04
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 3, 2025
ac343de
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 3, 2025
f3da344
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 3, 2025
a416d62
making next steps style as red
abzokhattab Dec 3, 2025
611c8a7
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 3, 2025
eba8d9c
minor edit
abzokhattab Dec 3, 2025
dd7731f
Replace review with view inside the preview actions
abzokhattab Dec 3, 2025
3468453
fixing tests
abzokhattab Dec 3, 2025
8f6467f
code refactoring
abzokhattab Dec 3, 2025
b654fa7
fixing eslint
abzokhattab Dec 3, 2025
35edd0c
showing view in offline mode and hide submit when report is submitted
abzokhattab Dec 3, 2025
fee83d9
fixing tests
abzokhattab Dec 3, 2025
189838e
minor cleanup
abzokhattab Dec 3, 2025
fa47283
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 3, 2025
4012421
Refactoring test cases
abzokhattab Dec 4, 2025
15d27b1
refactoring
abzokhattab Dec 9, 2025
5b243b0
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 10, 2025
00c5f79
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 10, 2025
b34a357
Reset Mobile-Expensify to match main
abzokhattab Dec 10, 2025
641a30f
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 11, 2025
ad704ea
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 11, 2025
9141eb5
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 15, 2025
0a42a29
fix ts errors
abzokhattab Dec 15, 2025
ace86f7
fixing failing tests
abzokhattab Dec 15, 2025
409422d
code refactor to enable submit on preview even though there are errors
abzokhattab Dec 16, 2025
735e145
fixing eslint
abzokhattab Dec 16, 2025
6d09f6a
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 16, 2025
379b9c8
fixing eslint
abzokhattab Dec 16, 2025
b7564b0
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 16, 2025
d4718b8
fix: track DEW pending submit via reportMetadata and only show offlin…
abzokhattab Dec 17, 2025
7c916a6
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 17, 2025
c41a50c
fix: make LHN preview consistent with report view for DEW pending state
abzokhattab Dec 17, 2025
5927c42
fixing react complience err
abzokhattab Dec 17, 2025
0ceabc0
fixng test
abzokhattab Dec 17, 2025
2b15c35
fixing tests
abzokhattab Dec 17, 2025
9bd2037
code refactoring
abzokhattab Dec 18, 2025
f552f43
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 18, 2025
f681f8d
fixing ts errors
abzokhattab Dec 19, 2025
d785f83
delete the optimistic action on success because the backend provides …
abzokhattab Dec 19, 2025
5e0448b
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 19, 2025
13fb98c
minor edit
abzokhattab Dec 19, 2025
962da45
remove expense failed action from optimitic values on success
abzokhattab Dec 22, 2025
2823ce9
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 22, 2025
a02a2ef
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Dec 22, 2025
b8c31a3
hide submited action when submiting while online
abzokhattab Dec 30, 2025
c6ed411
Skip optimistic submit action for online DEW submissions
abzokhattab Jan 1, 2026
70e36ab
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Jan 1, 2026
cafb2f2
fixing ts
abzokhattab Jan 1, 2026
153b035
Refactor handleActionButtonPress to use object param
abzokhattab Jan 1, 2026
031ff98
fixing eslint
abzokhattab Jan 1, 2026
aaa680d
fixing lint
abzokhattab Jan 1, 2026
8bd413a
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Jan 5, 2026
91a47a9
fixing test
abzokhattab Jan 5, 2026
8fe40a4
Merge remote-tracking branch 'origin' into dew-submit-report
abzokhattab Jan 5, 2026
6867379
fix: `getPersonalPolicy` is deprecated inside Search.ts
abzokhattab Jan 5, 2026
68dc280
making personalPolicyID as required
abzokhattab Jan 6, 2026
c77cada
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Jan 6, 2026
5c278a1
fixing ts
abzokhattab Jan 6, 2026
f33388d
fixing ts
abzokhattab Jan 6, 2026
f0046ba
prettier fix
abzokhattab Jan 6, 2026
b4edff8
refactor: remove usePersonalPolicy and use useOnyx directly in Search…
abzokhattab Jan 6, 2026
ca67273
Merge remote-tracking branch 'origin/main' into dew-submit-report
abzokhattab Jan 6, 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
7 changes: 7 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ const CONST = {
NO_OPTIMISTIC_TRANSACTION_THREADS: 'noOptimisticTransactionThreads',
UBER_FOR_BUSINESS: 'uberForBusiness',
CUSTOM_REPORT_NAMES: 'newExpensifyCustomReportNames',
NEW_DOT_DEW: 'newDotDEW',
GPS_MILEAGE: 'gpsMileage',
},
BUTTON_STATES: {
Expand Down Expand Up @@ -1237,6 +1238,7 @@ const CONST = {
CREATED: 'CREATED',
DELETED_ACCOUNT: 'DELETEDACCOUNT', // Deprecated OldDot Action
DELETED_TRANSACTION: 'DELETEDTRANSACTION',
DEW_SUBMIT_FAILED: 'DEWSUBMITFAILED',
DISMISSED_VIOLATION: 'DISMISSEDVIOLATION',
DONATION: 'DONATION', // Deprecated OldDot Action
DYNAMIC_EXTERNAL_WORKFLOW_ROUTED: 'DYNAMICEXTERNALWORKFLOWROUTED',
Expand Down Expand Up @@ -1568,6 +1570,7 @@ const CONST = {
HOURGLASS: 'hourglass',
CHECKMARK: 'checkmark',
STOPWATCH: 'stopwatch',
DOT_INDICATOR: 'dotIndicator',
},
ETA_KEY: {
SHORTLY: 'shortly',
Expand Down Expand Up @@ -3980,6 +3983,10 @@ const CONST = {
DELETE: 'delete',
UPDATE: 'update',
},
EXPENSE_PENDING_ACTION: {
SUBMIT: 'SUBMIT',
APPROVE: 'APPROVE',
},
BRICK_ROAD_INDICATOR_STATUS: {
ERROR: 'error',
INFO: 'info',
Expand Down
4 changes: 4 additions & 0 deletions src/components/LHNOptionsList/LHNOptionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import type {BlockingViewProps} from '@components/BlockingViews/BlockingView';
import BlockingView from '@components/BlockingViews/BlockingView';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';

Check warning on line 13 in src/components/LHNOptionsList/LHNOptionsList.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'@components/Icon/Expensicons' import is restricted from being used by a pattern. Direct imports from Icon/Expensicons are deprecated. Please use lazy loading hooks instead. Use `useMemoizedLazyExpensifyIcons` from @hooks/useLazyAsset. See docs/LAZY_ICONS_AND_ILLUSTRATIONS.md for details

Check warning on line 13 in src/components/LHNOptionsList/LHNOptionsList.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'@components/Icon/Expensicons' import is restricted from being used. Direct imports from @components/Icon/Expensicons are deprecated. Please use lazy loading hooks instead. Use `useMemoizedLazyExpensifyIcons` from @hooks/useLazyAsset. See docs/LAZY_ICONS_AND_ILLUSTRATIONS.md for details
import {ScrollOffsetContext} from '@components/ScrollOffsetContextProvider';
import TextBlock from '@components/TextBlock';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
Expand Down Expand Up @@ -61,6 +61,7 @@
const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: false});
const [reportAttributes] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {selector: reportsSelector, canBeMissing: true});
const [reportNameValuePairs] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, {canBeMissing: true});
const [reportMetadataCollection] = useOnyx(ONYXKEYS.COLLECTION.REPORT_METADATA, {canBeMissing: true});
const [reportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS, {canBeMissing: false});
const [policy] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: false});
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {canBeMissing: true});
Expand Down Expand Up @@ -225,6 +226,7 @@
}
const movedFromReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${getMovedReportID(lastReportAction, CONST.REPORT.MOVE_TYPE.FROM)}`];
const movedToReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${getMovedReportID(lastReportAction, CONST.REPORT.MOVE_TYPE.TO)}`];
const itemReportMetadata = reportMetadataCollection?.[`${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`];
const lastMessageTextFromReport = getLastMessageTextForReport({
report: item,
lastActorDetails,
Expand All @@ -233,6 +235,7 @@
policy: itemPolicy,
isReportArchived: !!itemReportNameValuePairs?.private_isArchived,
policyForMovingExpensesID,
reportMetadata: itemReportMetadata,
});

const shouldShowRBRorGBRTooltip = firstReportIDWithGBRorRBR === reportID;
Expand Down Expand Up @@ -298,6 +301,7 @@
reports,
reportNameValuePairs,
reportActions,
reportMetadataCollection,
isOffline,
reportAttributes,
policy,
Expand Down
36 changes: 32 additions & 4 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,23 @@ import {getThreadReportIDsForTransactions, getTotalAmountForIOUReportPreviewButt
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types';
import type {ReportsSplitNavigatorParamList, RightModalNavigatorParamList, SearchFullscreenNavigatorParamList} from '@libs/Navigation/types';
import {buildOptimisticNextStepForPreventSelfApprovalsEnabled, buildOptimisticNextStepForStrictPolicyRuleViolations} from '@libs/NextStepUtils';
import {
buildOptimisticNextStepForDEWOfflineSubmission,
buildOptimisticNextStepForDynamicExternalWorkflowError,
buildOptimisticNextStepForPreventSelfApprovalsEnabled,
buildOptimisticNextStepForStrictPolicyRuleViolations,
} from '@libs/NextStepUtils';
import type {KYCFlowEvent, TriggerKYCFlow} from '@libs/PaymentUtils';
import {selectPaymentType} from '@libs/PaymentUtils';
import {getConnectedIntegration, getValidConnectedIntegration, hasDynamicExternalWorkflow} from '@libs/PolicyUtils';
import {getIOUActionForReportID, getOriginalMessage, getReportAction, isMoneyRequestAction} from '@libs/ReportActionsUtils';
import {getIOUActionForReportID, getOriginalMessage, getReportAction, hasPendingDEWSubmit, isMoneyRequestAction} from '@libs/ReportActionsUtils';
import {getAllExpensesToHoldIfApplicable, getReportPrimaryAction, isMarkAsResolvedAction} from '@libs/ReportPrimaryActionUtils';
import {getSecondaryExportReportActions, getSecondaryReportActions} from '@libs/ReportSecondaryActionUtils';
import {
changeMoneyRequestHoldStatus,
generateReportID,
getAddExpenseDropdownOptions,
getAllReportActionsErrorsAndReportActionThatRequiresAttention,
getIntegrationExportIcon,
getIntegrationNameFromExportMessage as getIntegrationNameFromExportMessageUtils,
getNextApproverAccountID,
Expand Down Expand Up @@ -243,6 +249,7 @@ function MoneyReportHeader({
'ReceiptPlus',
] as const);
const [lastDistanceExpenseType] = useOnyx(ONYXKEYS.NVP_LAST_DISTANCE_EXPENSE_TYPE, {canBeMissing: true});
const [reportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${moneyRequestReport?.reportID}`, {canBeMissing: true});
const {translate, localeCompare} = useLocalize();

const exportTemplates = useMemo(
Expand Down Expand Up @@ -315,6 +322,7 @@ function MoneyReportHeader({
const [allTransactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: true});
const {isBetaEnabled} = usePermissions();
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
const isDEWBetaEnabled = isBetaEnabled(CONST.BETAS.NEW_DOT_DEW);
const hasViolations = hasViolationsReportUtils(moneyRequestReport?.reportID, allTransactionViolations, accountID, email ?? '');

const [exportModalStatus, setExportModalStatus] = useState<ExportType | null>(null);
Expand Down Expand Up @@ -472,6 +480,22 @@ function MoneyReportHeader({

let optimisticNextStep = isBlockSubmitDueToPreventSelfApproval ? buildOptimisticNextStepForPreventSelfApprovalsEnabled() : nextStep;

// Check for DEW submit failed or pending - show appropriate next step
if (isDEWBetaEnabled && hasDynamicExternalWorkflow(policy) && moneyRequestReport?.statusNum === CONST.REPORT.STATUS_NUM.OPEN) {
const reportActionsObject = reportActions.reduce<OnyxTypes.ReportActions>((acc, action) => {
if (action.reportActionID) {
acc[action.reportActionID] = action;
}
return acc;
}, {});
const {errors} = getAllReportActionsErrorsAndReportActionThatRequiresAttention(moneyRequestReport, reportActionsObject);
if (errors?.dewSubmitFailed) {
optimisticNextStep = buildOptimisticNextStepForDynamicExternalWorkflowError(theme.danger);
} else if (isOffline && hasPendingDEWSubmit(reportMetadata, hasDynamicExternalWorkflow(policy))) {
optimisticNextStep = buildOptimisticNextStepForDEWOfflineSubmission();
}
}

if (isBlockSubmitDueToStrictPolicyRules && isReportOwner(moneyRequestReport) && isOpenExpenseReport(moneyRequestReport)) {
optimisticNextStep = buildOptimisticNextStepForStrictPolicyRuleViolations();
}
Expand Down Expand Up @@ -744,6 +768,7 @@ function MoneyReportHeader({
policy,
reportNameValuePairs,
reportActions,
reportMetadata,
isChatReportArchived,
invoiceReceiverPolicy,
isPaidAnimationRunning,
Expand All @@ -761,6 +786,7 @@ function MoneyReportHeader({
policy,
reportNameValuePairs,
reportActions,
reportMetadata,
isChatReportArchived,
invoiceReceiverPolicy,
currentUserLogin,
Expand Down Expand Up @@ -891,7 +917,7 @@ function MoneyReportHeader({
if (!moneyRequestReport || shouldBlockSubmit) {
return;
}
if (hasDynamicExternalWorkflow(policy)) {
if (hasDynamicExternalWorkflow(policy) && !isDEWBetaEnabled) {
showDWEModal();
return;
}
Expand Down Expand Up @@ -1052,6 +1078,7 @@ function MoneyReportHeader({
policy,
reportNameValuePairs,
reportActions,
reportMetadata,
policies,
isChatReportArchived,
});
Expand All @@ -1066,6 +1093,7 @@ function MoneyReportHeader({
policy,
reportNameValuePairs,
reportActions,
reportMetadata,
policies,
isChatReportArchived,
]);
Expand Down Expand Up @@ -1138,7 +1166,7 @@ function MoneyReportHeader({
if (!moneyRequestReport) {
return;
}
if (hasDynamicExternalWorkflow(policy)) {
if (hasDynamicExternalWorkflow(policy) && !isDEWBetaEnabled) {
showDWEModal();
return;
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/MoneyReportHeaderStatusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ type IconMap = Record<IconName, IconAsset>;
function MoneyReportHeaderStatusBar({nextStep}: MoneyReportHeaderStatusBarProps) {
const styles = useThemeStyles();
const theme = useTheme();
const icons = useMemoizedLazyExpensifyIcons(['Hourglass', 'Checkmark', 'Stopwatch']);
const icons = useMemoizedLazyExpensifyIcons(['Hourglass', 'Checkmark', 'Stopwatch', 'DotIndicator']);
const iconMap: IconMap = useMemo(
() => ({
[CONST.NEXT_STEP.ICONS.HOURGLASS]: icons.Hourglass,
[CONST.NEXT_STEP.ICONS.CHECKMARK]: icons.Checkmark,
[CONST.NEXT_STEP.ICONS.STOPWATCH]: icons.Stopwatch,
[CONST.NEXT_STEP.ICONS.DOT_INDICATOR]: icons.DotIndicator,
}),
[icons],
);
Expand All @@ -47,7 +48,7 @@ function MoneyReportHeaderStatusBar({nextStep}: MoneyReportHeaderStatusBarProps)
src={(nextStep?.icon && iconMap?.[nextStep.icon]) ?? icons.Hourglass}
height={variables.iconSizeSmall}
width={variables.iconSizeSmall}
fill={theme.icon}
fill={nextStep?.iconFill ?? theme.icon}
/>
</View>
<View style={[styles.dFlex, styles.flexRow, styles.flexShrink1]}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {getTotalAmountForIOUReportPreviewButton} from '@libs/MoneyRequestReportU
import Navigation from '@libs/Navigation/Navigation';
import Performance from '@libs/Performance';
import {getConnectedIntegration, hasDynamicExternalWorkflow} from '@libs/PolicyUtils';
import {hasPendingDEWSubmit} from '@libs/ReportActionsUtils';
import {getInvoicePayerName} from '@libs/ReportNameUtils';
import getReportPreviewAction from '@libs/ReportPreviewActionUtils';
import {
Expand Down Expand Up @@ -125,6 +126,7 @@ function MoneyRequestReportPreviewContent({
forwardedFSClass,
}: MoneyRequestReportPreviewContentProps) {
const [chatReportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${chatReportID}`, {canBeMissing: true, allowStaleData: true});
const [iouReportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${iouReportID}`, {canBeMissing: true});
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});
const [iouReportNextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${iouReportID}`, {canBeMissing: true});
const activePolicy = usePolicy(activePolicyID);
Expand Down Expand Up @@ -172,6 +174,7 @@ function MoneyRequestReportPreviewContent({
const {isBetaEnabled} = usePermissions();
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: true});
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
const isDEWBetaEnabled = isBetaEnabled(CONST.BETAS.NEW_DOT_DEW);
const hasViolations = hasViolationsReportUtils(iouReport?.reportID, transactionViolations, currentUserAccountID, currentUserEmail);

const getCanIOUBePaid = useCallback(
Expand Down Expand Up @@ -286,7 +289,7 @@ function MoneyRequestReportPreviewContent({
);

const confirmApproval = () => {
if (hasDynamicExternalWorkflow(policy)) {
if (hasDynamicExternalWorkflow(policy) && !isDEWBetaEnabled) {
setIsDEWModalVisible(true);
return;
}
Expand Down Expand Up @@ -559,6 +562,8 @@ function MoneyRequestReportPreviewContent({
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(iouReportID, undefined, undefined, Navigation.getActiveRoute()));
}, [iouReportID]);

const isDEWPolicy = hasDynamicExternalWorkflow(policy);
const isDEWSubmitPending = hasPendingDEWSubmit(iouReportMetadata, isDEWPolicy);
const reportPreviewAction = useMemo(() => {
return getReportPreviewAction({
isReportArchived: isIouReportArchived || isChatReportArchived,
Expand All @@ -571,6 +576,7 @@ function MoneyRequestReportPreviewContent({
isPaidAnimationRunning,
isApprovedAnimationRunning,
isSubmittingAnimationRunning,
isDEWSubmitPending,
violationsData: transactionViolations,
});
}, [
Expand All @@ -586,6 +592,7 @@ function MoneyRequestReportPreviewContent({
isApprovedAnimationRunning,
isSubmittingAnimationRunning,
transactionViolations,
isDEWSubmitPending,
]);

const addExpenseDropdownOptions = useMemo(
Expand All @@ -602,7 +609,7 @@ function MoneyRequestReportPreviewContent({
success={isWaitingForSubmissionFromCurrentUser}
text={translate('common.submit')}
onPress={() => {
if (hasDynamicExternalWorkflow(policy)) {
if (hasDynamicExternalWorkflow(policy) && !isDEWBetaEnabled) {
setIsDEWModalVisible(true);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ function TransactionPreviewContent({
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getNonEmptyStringOnyxID(report?.reportID)}`, {canBeMissing: true});
const isChatReportArchived = useReportIsArchived(chatReport?.reportID);
const currentUserDetails = useCurrentUserPersonalDetails();
const currentUserEmail = currentUserDetails.email ?? '';
const currentUserAccountID = currentUserDetails.accountID;
const transactionPreviewCommonArguments = useMemo(
() => ({
iouReport: report,
Expand All @@ -105,10 +107,11 @@ function TransactionPreviewContent({
...transactionPreviewCommonArguments,
areThereDuplicates,
isReportAPolicyExpenseChat,
currentUserEmail: currentUserDetails.email ?? '',
currentUserAccountID: currentUserDetails.accountID,
currentUserEmail,
currentUserAccountID,
reportActions,
}),
[areThereDuplicates, transactionPreviewCommonArguments, isReportAPolicyExpenseChat, currentUserDetails.email, currentUserDetails.accountID],
[areThereDuplicates, transactionPreviewCommonArguments, isReportAPolicyExpenseChat, currentUserEmail, currentUserAccountID, reportActions],
);

const {shouldShowRBR, shouldShowMerchant, shouldShowSplitShare, shouldShowTag, shouldShowCategory, shouldShowSkeleton, shouldShowDescription} = conditionals;
Expand All @@ -126,11 +129,11 @@ function TransactionPreviewContent({
shouldShowRBR,
violationMessage,
reportActions,
currentUserEmail: currentUserDetails.email ?? '',
currentUserAccountID: currentUserDetails.accountID,
currentUserEmail,
currentUserAccountID,
originalTransaction,
}),
[transactionPreviewCommonArguments, shouldShowRBR, violationMessage, reportActions, currentUserDetails.email, currentUserDetails.accountID, originalTransaction],
[transactionPreviewCommonArguments, shouldShowRBR, violationMessage, reportActions, currentUserEmail, currentUserAccountID, originalTransaction],
);
const getTranslatedText = (item: TranslationPathOrText) => (item.translationPath ? translate(item.translationPath) : (item.text ?? ''));

Expand Down
6 changes: 6 additions & 0 deletions src/components/Search/SearchList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ type SearchListProps = Pick<FlashListProps<SearchListItem>, 'onScroll' | 'conten
/** Callback to fire when DEW modal should be opened */
onDEWModalOpen?: () => void;

/** Whether the DEW beta flag is enabled */
isDEWBetaEnabled?: boolean;

/** Selected transactions for determining isSelected state */
selectedTransactions: SelectedTransactions;

Expand Down Expand Up @@ -180,6 +183,7 @@ function SearchList({
violations,
customCardNames,
onDEWModalOpen,
isDEWBetaEnabled,
selectedTransactions,
ref,
}: SearchListProps) {
Expand Down Expand Up @@ -404,6 +408,7 @@ function SearchList({
groupBy={groupBy}
searchType={type}
onDEWModalOpen={onDEWModalOpen}
isDEWBetaEnabled={isDEWBetaEnabled}
userWalletTierName={userWalletTierName}
isUserValidated={isUserValidated}
personalDetails={personalDetails}
Expand Down Expand Up @@ -446,6 +451,7 @@ function SearchList({
isOffline,
violations,
onDEWModalOpen,
isDEWBetaEnabled,
customCardNames,
],
);
Expand Down
4 changes: 4 additions & 0 deletions src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
import usePrevious from '@hooks/usePrevious';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useSearchHighlightAndScroll from '@hooks/useSearchHighlightAndScroll';
Expand Down Expand Up @@ -205,6 +206,8 @@ function Search({
const {shouldUseNarrowLayout} = useResponsiveLayout();
const styles = useThemeStyles();
const [isDEWModalVisible, setIsDEWModalVisible] = useState(false);
const {isBetaEnabled} = usePermissions();
const isDEWBetaEnabled = isBetaEnabled(CONST.BETAS.NEW_DOT_DEW);

const handleDEWModalOpen = useCallback(() => {
if (onDEWModalOpen) {
Expand Down Expand Up @@ -1045,6 +1048,7 @@ function Search({
shouldPreventLongPressRow={isChat || isTask}
isFocused={isFocused}
onDEWModalOpen={handleDEWModalOpen}
isDEWBetaEnabled={isDEWBetaEnabled}
SearchTableHeader={
!shouldShowTableHeader ? undefined : (
<View style={[!isTask && styles.pr8, styles.flex1]}>
Expand Down
Loading
Loading