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
63 changes: 43 additions & 20 deletions src/libs/actions/Report/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2618,7 +2618,7 @@ function navigateToAndOpenReport({

if (!shouldRevalidateExistingChat) {
if (isOnboardingPending) {
openReport({reportID: chat.reportID, introSelected, isSelfTourViewed, hasCompletedGuidedSetupFlow, betas, hasReportActions, currentUserAccountID});
openReport({reportID: chat.reportID, introSelected, isSelfTourViewed, hasCompletedGuidedSetupFlow, betas, hasReportActions, currentUserAccountID, conciergeChat});
}
navigateToReport(chat.reportID, {shouldDismissModal, ...linkToOptions});
return;
Expand Down Expand Up @@ -2807,8 +2807,11 @@ function navigateToAndOpenChildReport(
// The personal details of the child report participants (the current user and the parent action's actor).
participantsPersonalDetails: OnyxEntry<PersonalDetailsList>,
isSelfTourViewed: boolean | undefined,
conciergeChat: OnyxEntry<Report>,
) {
const report = childReport ?? createChildReport(childReport, parentReportAction, parentReport, currentUserAccountID, introSelected, betas, isSelfTourViewed, participantsPersonalDetails);
const report =
childReport ??
createChildReport(childReport, parentReportAction, parentReport, currentUserAccountID, introSelected, betas, isSelfTourViewed, participantsPersonalDetails, conciergeChat);
const backTo = Navigation.getActiveRoute();

// A money-request/expense child report must open in the wide/super-wide RHP (SEARCH_MONEY_REQUEST_REPORT in the
Expand Down Expand Up @@ -2856,6 +2859,7 @@ function createChildReport(
isSelfTourViewed: boolean | undefined,
// The personal details of the child report participants (the current user and the parent action's actor).
participantsPersonalDetails: OnyxEntry<PersonalDetailsList>,
conciergeChat: OnyxEntry<Report>,
): Report {
const participantAccountIDs = [...new Set([currentUserAccountID, Number(parentReportAction.actorAccountID)])];
// Threads from DMs and selfDMs don't have a chatType. All other threads inherit the chatType from their parent
Expand Down Expand Up @@ -2900,6 +2904,7 @@ function createChildReport(
isSelfTourViewed,
hasReportActions: false,
currentUserAccountID,
conciergeChat,
});
} else {
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${childReportID}`, newChat);
Expand All @@ -2912,28 +2917,43 @@ function createChildReport(
* Creates an explanation thread for a report action with reasoning
* Adds a "Please explain this to me." comment from the user
*/
// TODO: update to object structure https://github.com/Expensify/App/issues/73656
// eslint-disable-next-line @typescript-eslint/max-params
function explain(
childReport: OnyxEntry<Report>,
originalReport: OnyxEntry<Report>,
reportAction: OnyxEntry<ReportAction>,
translate: LocalizedTranslate,
currentUserAccountID: number,
introSelected: OnyxEntry<IntroSelected>,
betas: OnyxEntry<Beta[]>,
isSelfTourViewed: boolean | undefined,
delegateAccountID: number | undefined,
// The personal details of the explanation thread participants (the current user and the report action's actor).
participantsPersonalDetails: OnyxEntry<PersonalDetailsList>,
timezone: Timezone = CONST.DEFAULT_TIME_ZONE,
) {
type ExplainParams = {
childReport: OnyxEntry<Report>;
originalReport: OnyxEntry<Report>;
reportAction: OnyxEntry<ReportAction>;
translate: LocalizedTranslate;
currentUserAccountID: number;
introSelected: OnyxEntry<IntroSelected>;
betas: OnyxEntry<Beta[]>;
conciergeChat: OnyxEntry<Report>;
isSelfTourViewed: boolean | undefined;
delegateAccountID: number | undefined;
/** The personal details of the explanation thread participants (the current user and the report action's actor). */
participantsPersonalDetails: OnyxEntry<PersonalDetailsList>;
timezone?: Timezone;
};

function explain({
childReport,
originalReport,
reportAction,
translate,
currentUserAccountID,
introSelected,
betas,
conciergeChat,
isSelfTourViewed,
delegateAccountID,
participantsPersonalDetails,
timezone = CONST.DEFAULT_TIME_ZONE,
}: ExplainParams) {
if (!originalReport?.reportID || !reportAction) {
return;
}

// Check if explanation thread report already exists
const report = childReport ?? createChildReport(childReport, reportAction, originalReport, currentUserAccountID, introSelected, betas, isSelfTourViewed, participantsPersonalDetails);
const report =
childReport ?? createChildReport(childReport, reportAction, originalReport, currentUserAccountID, introSelected, betas, isSelfTourViewed, participantsPersonalDetails, conciergeChat);

if (isSearchTopmostFullScreenRoute()) {
Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID: report.reportID, backTo: Navigation.getActiveRoute()}));
Expand Down Expand Up @@ -3832,6 +3852,7 @@ type ToggleSubscribeToChildReportParams = {
isSelfTourViewed: boolean | undefined;
hasCompletedGuidedSetupFlow: boolean | undefined;
betas: OnyxEntry<Beta[]>;
conciergeChat: OnyxEntry<Report>;
prevNotificationPreference: NotificationPreference | undefined;
personalDetails: OnyxEntry<PersonalDetailsList>;
hasReportActions: boolean;
Expand All @@ -3854,12 +3875,13 @@ function toggleSubscribeToChildReport({
isSelfTourViewed,
hasCompletedGuidedSetupFlow,
betas,
conciergeChat,
prevNotificationPreference,
personalDetails,
hasReportActions,
}: ToggleSubscribeToChildReportParams) {
if (childReportID) {
openReport({reportID: childReportID, introSelected, betas, isSelfTourViewed, hasCompletedGuidedSetupFlow, hasReportActions, currentUserAccountID});
openReport({reportID: childReportID, introSelected, betas, isSelfTourViewed, hasCompletedGuidedSetupFlow, hasReportActions, currentUserAccountID, conciergeChat});
const parentReportActionID = parentReportAction.reportActionID;
if (!prevNotificationPreference || isHiddenForCurrentUser(prevNotificationPreference)) {
updateNotificationPreference(
Expand Down Expand Up @@ -3906,6 +3928,7 @@ function toggleSubscribeToChildReport({
isSelfTourViewed,
hasCompletedGuidedSetupFlow,
betas,
conciergeChat,
hasReportActions: false,
currentUserAccountID,
});
Expand Down
2 changes: 2 additions & 0 deletions src/pages/Share/ShareDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function ShareDetailsPage({route}: ShareDetailsPageProps) {
const [isDraftReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_DRAFT}${reportOrAccountID}`, {selector: isDraftReportSelector});
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const [conciergeChat] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${conciergeReportID}`);
const delegateAccountID = useDelegateAccountID();

const reportAttributesDerived = useReportAttributes();
Expand Down Expand Up @@ -175,6 +176,7 @@ function ShareDetailsPage({route}: ShareDetailsPageProps) {
personalDetails,
newReportObject: report,
betas,
conciergeChat,
hasReportActions: false,
currentUserAccountID: personalDetail.accountID,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ function BaseReportActionContextMenu({
const [guidedSetupAndTourStatus] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: guidedSetupAndTourStatusSelector});
const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST);
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const [conciergeChat] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${conciergeReportID}`);
const personalDetails = usePersonalDetails();
const reportAttributes = useReportAttributes();
const delegateAccountID = useDelegateAccountID();
Expand Down Expand Up @@ -440,6 +441,7 @@ function BaseReportActionContextMenu({
bankAccountList,
isOffline,
conciergeReportID,
conciergeChat,
delegateAccountID,
reportAttributes,
originalReportOfUnapprovedTransaction,
Expand Down
61 changes: 45 additions & 16 deletions src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ type ContextMenuActionPayload = {
bankAccountList: OnyxEntry<BankAccountList>;
isOffline: boolean;
conciergeReportID: string | undefined;
conciergeChat: OnyxEntry<ReportType>;
originalReportOfUnapprovedTransaction?: OnyxEntry<ReportType>;
delegateAccountID: number | undefined;
reportAttributes: ReportAttributesDerivedValue['reports'] | undefined;
Expand Down Expand Up @@ -502,17 +503,27 @@ const ContextMenuActions: ContextMenuAction[] = [
}
return !shouldDisableThread(reportAction, isThreadReportParentAction, isArchivedRoom);
},
onPress: (closePopover, {reportAction, childReport, originalReport, currentUserAccountID, introSelected, betas, isSelfTourViewed, personalDetails}) => {
onPress: (closePopover, {reportAction, childReport, originalReport, currentUserAccountID, introSelected, betas, isSelfTourViewed, personalDetails, conciergeChat}) => {
const participantsPersonalDetails = getParticipantsPersonalDetails([currentUserAccountID, Number(reportAction.actorAccountID)], personalDetails);
if (closePopover) {
hideContextMenu(false, () => {
KeyboardUtils.dismiss().then(() => {
navigateToAndOpenChildReport(childReport, reportAction, originalReport, currentUserAccountID, introSelected, betas, participantsPersonalDetails, isSelfTourViewed);
navigateToAndOpenChildReport(
childReport,
reportAction,
originalReport,
currentUserAccountID,
introSelected,
betas,
participantsPersonalDetails,
isSelfTourViewed,
conciergeChat,
);
});
});
return;
}
navigateToAndOpenChildReport(childReport, reportAction, originalReport, currentUserAccountID, introSelected, betas, participantsPersonalDetails, isSelfTourViewed);
navigateToAndOpenChildReport(childReport, reportAction, originalReport, currentUserAccountID, introSelected, betas, participantsPersonalDetails, isSelfTourViewed, conciergeChat);
},
getDescription: () => {},
sentryLabel: CONST.SENTRY_LABEL.CONTEXT_MENU.REPLY_IN_THREAD,
Expand Down Expand Up @@ -548,7 +559,7 @@ const ContextMenuActions: ContextMenuAction[] = [
},
onPress: (
closePopover,
{reportAction, childReport, originalReport, translate, currentUserPersonalDetails, introSelected, betas, isSelfTourViewed, delegateAccountID, personalDetails},
{reportAction, childReport, originalReport, translate, currentUserPersonalDetails, introSelected, betas, isSelfTourViewed, delegateAccountID, personalDetails, conciergeChat},
) => {
if (!originalReport?.reportID) {
return;
Expand All @@ -559,37 +570,39 @@ const ContextMenuActions: ContextMenuAction[] = [
if (closePopover) {
hideContextMenu(false, () => {
KeyboardUtils.dismiss().then(() => {
explain(
explain({
childReport,
originalReport,
reportAction,
translate,
currentUserPersonalDetails.accountID,
currentUserAccountID: currentUserPersonalDetails.accountID,
introSelected,
betas,
conciergeChat,
isSelfTourViewed,
delegateAccountID,
participantsPersonalDetails,
currentUserPersonalDetails?.timezone,
);
timezone: currentUserPersonalDetails?.timezone,
});
});
});
return;
}

explain(
explain({
childReport,
originalReport,
reportAction,
translate,
currentUserPersonalDetails.accountID,
currentUserAccountID: currentUserPersonalDetails.accountID,
introSelected,
betas,
conciergeChat,
isSelfTourViewed,
delegateAccountID,
participantsPersonalDetails,
currentUserPersonalDetails?.timezone,
);
timezone: currentUserPersonalDetails?.timezone,
});
},
getDescription: () => {},
sentryLabel: CONST.SENTRY_LABEL.CONTEXT_MENU.EXPLAIN,
Expand Down Expand Up @@ -620,12 +633,24 @@ const ContextMenuActions: ContextMenuAction[] = [
!isChronosReport,
onPress: (
closePopover,
{reportID, reportActions, originalReportActions, originalReportID, reportAction, moneyRequestAction, introSelected, betas, childReportActions, currentUserAccountID},
{
reportID,
reportActions,
originalReportActions,
originalReportID,
reportAction,
moneyRequestAction,
introSelected,
betas,
childReportActions,
currentUserAccountID,
conciergeChat,
},
) => {
if (isMoneyRequestAction(reportAction) || isMoneyRequestAction(moneyRequestAction)) {
const editExpense = () => {
const childReportID = reportAction?.childReportID;
openReport({reportID: childReportID, introSelected, betas, hasReportActions: !!childReportActions, currentUserAccountID});
openReport({reportID: childReportID, introSelected, betas, hasReportActions: !!childReportActions, currentUserAccountID, conciergeChat});
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(childReportID));
};
if (closePopover) {
Expand Down Expand Up @@ -800,7 +825,7 @@ const ContextMenuActions: ContextMenuAction[] = [
},
onPress: (
closePopover,
{reportAction, currentUserAccountID, originalReport, introSelected, isSelfTourViewed, hasCompletedGuidedSetupFlow, betas, personalDetails, childReportActions},
{reportAction, currentUserAccountID, originalReport, introSelected, isSelfTourViewed, hasCompletedGuidedSetupFlow, betas, personalDetails, childReportActions, conciergeChat},
) => {
const childReportNotificationPreference = getChildReportNotificationPreferenceReportUtils(reportAction);
if (closePopover) {
Expand All @@ -815,6 +840,7 @@ const ContextMenuActions: ContextMenuAction[] = [
isSelfTourViewed,
hasCompletedGuidedSetupFlow,
betas,
conciergeChat,
prevNotificationPreference: childReportNotificationPreference,
personalDetails,
hasReportActions: !!childReportActions,
Expand All @@ -833,6 +859,7 @@ const ContextMenuActions: ContextMenuAction[] = [
isSelfTourViewed,
hasCompletedGuidedSetupFlow,
betas,
conciergeChat,
prevNotificationPreference: childReportNotificationPreference,
personalDetails,
hasReportActions: !!childReportActions,
Expand Down Expand Up @@ -866,7 +893,7 @@ const ContextMenuActions: ContextMenuAction[] = [
},
onPress: (
closePopover,
{reportAction, currentUserAccountID, originalReport, introSelected, isSelfTourViewed, hasCompletedGuidedSetupFlow, betas, personalDetails, childReportActions},
{reportAction, currentUserAccountID, originalReport, introSelected, isSelfTourViewed, hasCompletedGuidedSetupFlow, betas, personalDetails, childReportActions, conciergeChat},
) => {
const childReportNotificationPreference = getChildReportNotificationPreferenceReportUtils(reportAction);
if (closePopover) {
Expand All @@ -881,6 +908,7 @@ const ContextMenuActions: ContextMenuAction[] = [
isSelfTourViewed,
hasCompletedGuidedSetupFlow,
betas,
conciergeChat,
prevNotificationPreference: childReportNotificationPreference,
personalDetails,
hasReportActions: !!childReportActions,
Expand All @@ -899,6 +927,7 @@ const ContextMenuActions: ContextMenuAction[] = [
isSelfTourViewed,
hasCompletedGuidedSetupFlow,
betas,
conciergeChat,
prevNotificationPreference: childReportNotificationPreference,
personalDetails,
hasReportActions: !!childReportActions,
Expand Down
13 changes: 8 additions & 5 deletions src/pages/inbox/report/ReportActionItemMessageWithExplain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ function ReportActionItemMessageWithExplain({message, action, childReport, origi
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const [conciergeChat] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${conciergeReportID}`);
const delegateAccountID = useDelegateAccountID();
const personalDetails = usePersonalDetails();

Expand All @@ -62,19 +64,20 @@ function ReportActionItemMessageWithExplain({message, action, childReport, origi
// Handle the special "Explain" link
if (href.endsWith(CONST.CONCIERGE_EXPLAIN_LINK_PATH)) {
const participantsPersonalDetails = getParticipantsPersonalDetails([personalDetail.accountID, Number(action?.actorAccountID)], personalDetails);
explain(
explain({
childReport,
originalReport,
action,
reportAction: action,
translate,
personalDetail.accountID,
currentUserAccountID: personalDetail.accountID,
introSelected,
betas,
conciergeChat,
isSelfTourViewed,
delegateAccountID,
participantsPersonalDetails,
personalDetail?.timezone,
);
timezone: personalDetail?.timezone,
});
return;
}

Expand Down
Loading
Loading