Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: delete money request if failed to create chat #44142

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
dcc9ac9
fix: delete money request if failed to create chat
dominictb Jun 21, 2024
ed0b37e
fix: add function to swap err message for local translation
dominictb Jun 21, 2024
caae66e
Merge remote-tracking branch 'origin/main' into fix/42950-clean-dist-…
dominictb Jun 22, 2024
7936055
fix: lint and prettier
dominictb Jun 22, 2024
68c4ca7
fix: check optimistic report before cleaning up money request
dominictb Jun 24, 2024
083c790
chore: add translation
dominictb Jun 24, 2024
5951c38
fix: lint
dominictb Jun 24, 2024
7a9c89b
Merge remote-tracking branch 'origin/main' into fix/42950-clean-dist-…
dominictb Jun 26, 2024
b383383
fix: improve translation key swapping logic
dominictb Jun 26, 2024
65bd81d
fix: comment
dominictb Jun 28, 2024
9b67b44
Merge remote-tracking branch 'origin/main' into fix/42950-clean-dist-…
dominictb Jul 4, 2024
041bed4
fix: set errors and IOUTransactionID to null
dominictb Jul 4, 2024
41768f4
fix: typescript issue
dominictb Jul 4, 2024
bd32dd9
Merge remote-tracking branch 'origin/main' into fix/42950-clean-dist-…
dominictb Jul 9, 2024
0590632
fix: resolve typescript issues
dominictb Jul 10, 2024
21eafea
fix: prettier
dominictb Jul 10, 2024
3730797
fix: update comments and clean up implementation
dominictb Jul 12, 2024
83c0c3f
Merge remote-tracking branch 'origin/main' into fix/42950-clean-dist-…
dominictb Jul 12, 2024
51b8106
Merge remote-tracking branch 'origin/main' into fix/42950-clean-dist-…
dominictb Jul 16, 2024
4b79f38
fix: revert "swapForTranslation" change
dominictb Jul 16, 2024
313b1ca
Merge remote-tracking branch 'origin/main' into fix/42950-clean-dist-…
dominictb Jul 17, 2024
6ea8fc6
Remove en translation messsage
dominictb Jul 17, 2024
d71f595
Remove es translation message
dominictb Jul 17, 2024
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
8 changes: 8 additions & 0 deletions src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,14 @@ function MoneyRequestView({
if (!transaction?.transactionID) {
return;
}

const isCreateChatErrored = !!report?.errorFields?.createChat;
Copy link
Contributor

Choose a reason for hiding this comment

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

This caused a regression here, more details: #46662 (comment)

if ((isCreateChatErrored || !!report.isOptimisticReport) && parentReportAction) {
const urlToNavigateBack = IOU.cleanUpMoneyRequest(transaction.transactionID, parentReportAction, true);
Navigation.goBack(urlToNavigateBack);
Comment on lines +416 to +417
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, this caused the following issue: #50022
Details can be found in this proposal: #50022 (comment)
PR: #51940

return;
}

if (transaction.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) {
if (chatReport?.reportID && ReportUtils.getAddWorkspaceRoomOrChatReportErrors(chatReport)) {
Report.navigateToConciergeChatAndDeleteReport(chatReport.reportID, true, true);
Expand Down
100 changes: 51 additions & 49 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {fastMerge} from 'expensify-common';
import _ from 'lodash';
import lodashFindLast from 'lodash/findLast';
import type {OnyxCollection, OnyxCollectionInputValue, OnyxEntry, OnyxUpdate} from 'react-native-onyx';
import type {NullishDeep, OnyxCollection, OnyxEntry, OnyxUpdate} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import CONST from '@src/CONST';
Expand All @@ -10,8 +10,8 @@ import ONYXKEYS from '@src/ONYXKEYS';
import type {OnyxInputOrEntry} from '@src/types/onyx';
import type {JoinWorkspaceResolution, OriginalMessageExportIntegration} from '@src/types/onyx/OriginalMessage';
import type Report from '@src/types/onyx/Report';
import type {Message, OldDotReportAction, OriginalMessage, ReportActions} from '@src/types/onyx/ReportAction';
import type ReportAction from '@src/types/onyx/ReportAction';
import type {Message, OldDotReportAction, OriginalMessage, ReportActions} from '@src/types/onyx/ReportAction';
import type ReportActionName from '@src/types/onyx/ReportActionName';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import DateUtils from './DateUtils';
Expand Down Expand Up @@ -715,10 +715,12 @@ function replaceBaseURLInPolicyChangeLogAction(reportAction: ReportAction): Repo
return updatedReportAction;
}

function getLastVisibleAction(reportID: string, actionsToMerge: OnyxCollection<ReportAction> | OnyxCollectionInputValue<ReportAction> = {}): OnyxEntry<ReportAction> {
function getLastVisibleAction(reportID: string, actionsToMerge: Record<string, NullishDeep<ReportAction> | null> = {}): OnyxEntry<ReportAction> {
let reportActions: Array<ReportAction | null | undefined> = [];
if (!_.isEmpty(actionsToMerge)) {
reportActions = Object.values(fastMerge(allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`] ?? {}, actionsToMerge ?? {}, true));
reportActions = Object.values(fastMerge(allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`] ?? {}, actionsToMerge ?? {}, true)) as Array<
ReportAction | null | undefined
>;
} else {
reportActions = Object.values(allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`] ?? {});
}
Expand All @@ -732,7 +734,7 @@ function getLastVisibleAction(reportID: string, actionsToMerge: OnyxCollection<R

function getLastVisibleMessage(
reportID: string,
actionsToMerge: OnyxCollection<ReportAction> | OnyxCollectionInputValue<ReportAction> = {},
actionsToMerge: Record<string, NullishDeep<ReportAction> | null> = {},
reportAction: OnyxInputOrEntry<ReportAction> | undefined = undefined,
): LastVisibleMessage {
const lastVisibleAction = reportAction ?? getLastVisibleAction(reportID, actionsToMerge);
Expand Down Expand Up @@ -1534,92 +1536,92 @@ function getExportIntegrationActionFragments(reportAction: OnyxEntry<ReportActio
}

export {
doesReportHaveVisibleActions,
extractLinksFromMessageHtml,
getActionableMentionWhisperMessage,
getAllReportActions,
getCombinedReportActions,
getDismissedViolationMessageText,
getOneTransactionThreadReportID,
getFilteredForOneTransactionView,
getFirstVisibleReportActionID,
getIOUActionForReportID,
getIOUReportIDFromReportActionPreview,
getLastClosedReportAction,
getLastVisibleAction,
getLastVisibleMessage,
getLatestReportActionFromOnyxData,
getLinkedTransactionID,
getMemberChangeMessageFragment,
getMemberChangeMessagePlainText,
getMessageOfOldDotReportAction,
getMostRecentIOURequestActionID,
getMostRecentReportActionLastModified,
getNumberOfMoneyRequests,
getOneTransactionThreadReportID,
getOriginalMessage,
getParentReportAction,
getReportAction,
getReportActionHtml,
getReportActionMessage,
getReportActionMessageText,
getWhisperedTo,
isApprovedOrSubmittedReportAction,
getReportActionText,
getReportPreviewAction,
getSortedReportActions,
getCombinedReportActions,
getSortedReportActionsForDisplay,
getTextFromHtml,
getTrackExpenseActionableWhisper,
getWhisperedTo,
hasRequestFromCurrentAccount,
isActionOfType,
isActionableJoinRequest,
isActionableJoinRequestPending,
isActionableMentionWhisper,
isActionableReportMentionWhisper,
isActionableTrackExpense,
isAddCommentAction,
isApprovedOrSubmittedReportAction,
isChronosOOOListAction,
isClosedAction,
isConsecutiveActionMadeByPreviousActor,
isCreatedAction,
isCreatedTaskReportAction,
isCurrentActionUnread,
isDeletedAction,
isDeletedParentAction,
isLinkedTransactionHeld,
isMemberChangeAction,
isExportIntegrationAction,
isMessageDeleted,
isModifiedExpenseAction,
isMoneyRequestAction,
isNotifiableReportAction,
isOldDotReportAction,
isPayAction,
isPendingRemove,
isReversedTransaction,
isPolicyChangeLogAction,
isReimbursementDeQueuedAction,
isReimbursementQueuedAction,
isRenamedAction,
isReportActionAttachment,
isReportActionDeprecated,
isReportPreviewAction,
isResolvedActionTrackExpense,
isReversedTransaction,
isRoomChangeLogAction,
isSentMoneyReportAction,
isSplitBillAction,
isTrackExpenseAction,
isPayAction,
isTaskAction,
doesReportHaveVisibleActions,
isThreadParentMessage,
isTrackExpenseAction,
isTransactionThread,
isTripPreview,
isWhisperAction,
isWhisperActionTargetedToOthers,
isReimbursementQueuedAction,
shouldReportActionBeVisible,
shouldHideNewMarker,
shouldReportActionBeVisible,
shouldReportActionBeVisibleAsLastAction,
hasRequestFromCurrentAccount,
getFirstVisibleReportActionID,
isMemberChangeAction,
getMemberChangeMessageFragment,
isOldDotReportAction,
getTrackExpenseActionableWhisper,
getMessageOfOldDotReportAction,
getMemberChangeMessagePlainText,
isReimbursementDeQueuedAction,
isActionableMentionWhisper,
isActionableReportMentionWhisper,
getActionableMentionWhisperMessage,
isCurrentActionUnread,
isActionableJoinRequest,
isActionableJoinRequestPending,
getReportActionText,
getReportActionHtml,
getReportActionMessage,
getOriginalMessage,
isActionOfType,
isActionableTrackExpense,
getAllReportActions,
isLinkedTransactionHeld,
wasActionTakenByCurrentUser,
isResolvedActionTrackExpense,
isClosedAction,
isRenamedAction,
isRoomChangeLogAction,
isInviteOrRemovedAction,
isChronosOOOListAction,
isAddCommentAction,
isPolicyChangeLogAction,
getTextFromHtml,
isTripPreview,
getIOUActionForReportID,
getFilteredForOneTransactionView,
isActionableAddPaymentCard,
getExportIntegrationActionFragments,
getExportIntegrationLastMessageText,
Expand Down
Loading
Loading