Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f16f7de
Revert "[CP Staging] Revert "fix: approve button is present after sub…
mkzie2 Aug 26, 2025
b344d45
fix missing merchant case
mkzie2 Aug 26, 2025
00afc44
fix test
mkzie2 Aug 26, 2025
93c84fc
run prettier
mkzie2 Aug 26, 2025
599dfbf
Merge branch 'main' into revert-69169-revert-67941-mkzie2-issue/67173
mkzie2 Sep 7, 2025
68987be
merge main
mkzie2 Sep 12, 2025
a1ff5c6
Merge branch 'main' into revert-69169-revert-67941-mkzie2-issue/67173
mkzie2 Sep 15, 2025
33380ee
Merge branch 'main' into revert-69169-revert-67941-mkzie2-issue/67173
mkzie2 Sep 16, 2025
7ed67e1
remove unnecessary test
mkzie2 Sep 18, 2025
a72e8ef
resolve conflict
mkzie2 Oct 21, 2025
85b09d4
remove unnecessary change
mkzie2 Oct 21, 2025
9ac3cb5
remove unused change
mkzie2 Oct 21, 2025
7a2903a
remove unused import
mkzie2 Oct 21, 2025
824d38e
resolve conflict
mkzie2 Oct 28, 2025
6a75ee3
Merge branch 'main' into revert-69169-revert-67941-mkzie2-issue/67173
mkzie2 Nov 7, 2025
a8f28ea
Merge branch 'main' into revert-69169-revert-67941-mkzie2-issue/67173
mkzie2 Nov 11, 2025
7578bd9
Merge branch 'main' into revert-69169-revert-67941-mkzie2-issue/67173
mkzie2 Nov 13, 2025
f02e967
Merge branch 'main' into revert-69169-revert-67941-mkzie2-issue/67173
mkzie2 Nov 22, 2025
186e784
fix lint and ts error
mkzie2 Nov 22, 2025
89fa1f6
Merge branch 'main' into revert-69169-revert-67941-mkzie2-issue/67173
mkzie2 Dec 15, 2025
db7b84d
Merge branch 'main' into revert-69169-revert-67941-mkzie2-issue/67173
mkzie2 Dec 15, 2025
7a3fcc5
Merge branch 'main' into revert-69169-revert-67941-mkzie2-issue/67173
mkzie2 Dec 24, 2025
92138d1
Merge branch 'main' into revert-69169-revert-67941-mkzie2-issue/67173
mkzie2 Dec 29, 2025
1e5b01a
Merge branch 'main' into revert-69169-revert-67941-mkzie2-issue/67173
mkzie2 Jan 26, 2026
fdd9ee1
Merge branch 'main' into revert-69169-revert-67941-mkzie2-issue/67173
mkzie2 Jan 28, 2026
b5ff761
fix: use new logics
mkzie2 Jan 28, 2026
70f025c
fix: remove tests
mkzie2 Jan 28, 2026
00c3c06
Merge branch 'main' into revert-69169-revert-67941-mkzie2-issue/67173
mkzie2 Feb 2, 2026
736e558
Merge branch 'main' into revert-69169-revert-67941-mkzie2-issue/67173
mkzie2 Feb 4, 2026
4ed5acc
Merge branch 'main' into revert-69169-revert-67941-mkzie2-issue/67173
mkzie2 Feb 13, 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
4 changes: 2 additions & 2 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ import {
buildOptimisticNextStepForDEWOffline,
buildOptimisticNextStepForDynamicExternalWorkflowApproveError,
buildOptimisticNextStepForDynamicExternalWorkflowSubmitError,
buildOptimisticNextStepForPreventSelfApprovalsEnabled,
buildOptimisticNextStepForStrictPolicyRuleViolations,
getReportNextStep,
} from '@libs/NextStepUtils';
import type {KYCFlowEvent, TriggerKYCFlow} from '@libs/PaymentUtils';
import {selectPaymentType} from '@libs/PaymentUtils';
Expand Down Expand Up @@ -508,7 +508,7 @@ function MoneyReportHeader({
hasDuplicates ||
shouldShowMarkAsResolved;

let optimisticNextStep = isBlockSubmitDueToPreventSelfApproval ? buildOptimisticNextStepForPreventSelfApprovalsEnabled() : nextStep;
let optimisticNextStep = getReportNextStep(nextStep, moneyRequestReport, transactions, policy, allTransactionViolations, email ?? '', accountID);

// Check for DEW submit/approve failed or pending - show appropriate next step
if (isDEWPolicy && (moneyRequestReport?.statusNum === CONST.REPORT.STATUS_NUM.OPEN || moneyRequestReport?.statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED)) {
Expand Down
65 changes: 63 additions & 2 deletions src/libs/NextStepUtils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {addMonths, format, isPast, setDate} from 'date-fns';
import {Str} from 'expensify-common';
import type {OnyxEntry} from 'react-native-onyx';
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import type {LocaleContextProps} from '@components/LocaleContextProvider';
import CONST from '@src/CONST';
import type {Policy, Report, ReportNextStepDeprecated} from '@src/types/onyx';
import type {Policy, Report, ReportNextStepDeprecated, Transaction, TransactionViolations} from '@src/types/onyx';
import type {ReportNextStep} from '@src/types/onyx/Report';
import type {Message} from '@src/types/onyx/ReportNextStepDeprecated';
import type DeepValueOf from '@src/types/utils/DeepValueOf';
Expand All @@ -20,8 +20,11 @@ import {
getPersonalDetailsForAccountID,
isExpenseReport,
isInvoiceReport,
isOpenExpenseReport,
isPayer,
isReportOwner,
} from './ReportUtils';
import {hasSubmissionBlockingViolations} from './TransactionUtils';

type BuildNextStepNewParams = {
report: OnyxEntry<Report>;
Expand Down Expand Up @@ -318,6 +321,30 @@ function buildOptimisticNextStepForPreventSelfApprovalsEnabled() {
return optimisticNextStep;
}

function buildOptimisticFixIssueNextStep() {
const optimisticNextStep: ReportNextStepDeprecated = {
type: 'neutral',
icon: CONST.NEXT_STEP.ICONS.HOURGLASS,
message: [
{
text: 'Waiting for ',
},
{
text: `you`,
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.

This change introduced #86252 by hardcoding 'you' in the next-step message, so admins also see "Waiting for you" instead of the submitter name

type: 'strong',
},
{
text: ' to ',
},
{
text: 'fix the issue(s)',
},
],
};

return optimisticNextStep;
}

function buildOptimisticNextStepForStrictPolicyRuleViolations() {
const optimisticNextStep: ReportNextStepDeprecated = {
type: 'alert',
Expand All @@ -332,6 +359,39 @@ function buildOptimisticNextStepForStrictPolicyRuleViolations() {
return optimisticNextStep;
}

function getReportNextStep(
currentNextStep: ReportNextStepDeprecated | undefined,
moneyRequestReport: OnyxEntry<Report>,
transactions: Array<OnyxEntry<Transaction>>,
policy: OnyxEntry<Policy>,
transactionViolations: OnyxCollection<TransactionViolations>,
currentUserEmail: string,
currentUserAccountID: number,
) {
const nextApproverAccountID = getNextApproverAccountID(moneyRequestReport);

if (
isOpenExpenseReport(moneyRequestReport) &&
transactions.length > 0 &&
transactions.every(
(transaction) => !!transaction && hasSubmissionBlockingViolations(transaction, transactionViolations, currentUserEmail, currentUserAccountID, moneyRequestReport, policy),
)
) {
return buildOptimisticFixIssueNextStep();
}

const isSubmitterSameAsNextApprover =
isReportOwner(moneyRequestReport) && (nextApproverAccountID === moneyRequestReport?.ownerAccountID || moneyRequestReport?.managerID === moneyRequestReport?.ownerAccountID);

// When prevent self-approval is enabled & the current user is submitter AND they're submitting to themselves, we need to show the optimistic next step
// We should always show this optimistic message for policies with preventSelfApproval
// to avoid any flicker during transitions between online/offline states
if (isSubmitterSameAsNextApprover && policy?.preventSelfApproval) {
return buildOptimisticNextStepForPreventSelfApprovalsEnabled();
}

return currentNextStep;
}
function buildOptimisticNextStepForDynamicExternalWorkflowSubmitError(iconFill?: string) {
const optimisticNextStep: ReportNextStepDeprecated = {
type: 'alert',
Expand Down Expand Up @@ -745,6 +805,7 @@ function buildNextStepNew(params: BuildNextStepNewParams): ReportNextStepDepreca
}

export {
getReportNextStep,
buildNextStepMessage,
buildOptimisticNextStep,
parseMessage,
Expand Down
Loading