Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import useResponsiveLayoutOnWideRHP from '@hooks/useResponsiveLayoutOnWideRHP';
import useThemeStyles from '@hooks/useThemeStyles';
import useUnreadMarker from '@hooks/useUnreadMarker';

import {isBillPayReport, shouldKeepBillPayActorHeader} from '@libs/BillPayReportActionUtils';
import {isConsecutiveChronosAutomaticTimerAction} from '@libs/ChronosUtils';
import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
import Navigation from '@libs/Navigation/Navigation';
Expand Down Expand Up @@ -43,10 +44,12 @@ import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import {getStableReportSelector} from '@src/selectors/Report';
import {pendingNewTransactionIDsSelector} from '@src/selectors/ReportMetaData';
import {isLinkedToBillSelector} from '@src/selectors/ReportNameValuePairs';
import type * as OnyxTypes from '@src/types/onyx';
import getEmptyArray from '@src/types/utils/getEmptyArray';

import type {LayoutChangeEvent} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';

import {useIsFocused, useRoute} from '@react-navigation/native';
import {getCustomAgentAccountIDs} from '@selectors/AgentZeroChat';
Expand Down Expand Up @@ -79,6 +82,15 @@ type MoneyRequestReportActionsListContentProps = MoneyRequestReportListProps & {
reportIDFromRoute: string | undefined;
};

function reportNameValuePairsSelector(reportNameValuePairs: OnyxEntry<OnyxTypes.ReportNameValuePairs>) {
return {
origin: reportNameValuePairs?.origin,
originalID: reportNameValuePairs?.originalID,
billID: reportNameValuePairs?.billID,
conciergeFeedbackForReportActionID: reportNameValuePairs?.conciergeFeedbackForReportActionID,
};
}

/**
* Renders the money-request report's unified list (transactions table + report actions). Composes the
* view's data/behavior hooks (`useMoneyRequestReportVisibleActions` / `useMoneyRequestReportPagination` /
Expand Down Expand Up @@ -141,15 +153,18 @@ function MoneyRequestReportActionsListContent({reportIDFromRoute, onLayout}: Mon
const isReportArchived = useReportIsArchived(reportID);
const canPerformWriteAction = canUserPerformWriteAction(report, isReportArchived);

const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${getNonEmptyStringOnyxID(reportID)}`);
const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${getNonEmptyStringOnyxID(reportID)}`, {
selector: reportNameValuePairsSelector,
});
const shouldShowHarvestCreatedAction = isHarvestCreatedExpenseReport(reportNameValuePairs?.origin, reportNameValuePairs?.originalID);
const isInvoiceLinkedToBill = isLinkedToBillSelector(reportNameValuePairs);

const {visibleReportActions, visibleReportActionsNewestFirst, lastAction, firstVisibleReportActionID} = useMoneyRequestReportVisibleActions({
reportID,
reportActions,
reportTransactionIDs,
canPerformWriteAction: !!canPerformWriteAction,
shouldShowHarvestCreatedAction,
shouldShowCreatedAction: shouldShowHarvestCreatedAction || isBillPayReport(reportStable, isInvoiceLinkedToBill),
isOffline,
isWaitingOnBankAccount: !!report?.isWaitingOnBankAccount,
});
Expand Down Expand Up @@ -281,8 +296,10 @@ function MoneyRequestReportActionsListContent({reportIDFromRoute, onLayout}: Mon
const previousReportAction = indexWithinReportActions > 0 ? displayReportActions.at(indexWithinReportActions - 1) : undefined;
const previousRun = previousReportAction ? runsByAnchorReportActionID.get(previousReportAction.reportActionID) : undefined;
const isAfterCollapsedRun = indexWithinReportActions > 0 && !!previousRun && !previousRun.isExpanded;

const displayAsGroup =
!isAfterCollapsedRun &&
!shouldKeepBillPayActorHeader(reportAction, previousReportAction, reportStable, isInvoiceLinkedToBill) &&
!isConsecutiveChronosAutomaticTimerAction(visibleReportActions, canonicalIndex, chatIncludesChronosWithID(reportAction?.reportID), isOffline) &&
hasNextActionMadeBySameActor(visibleReportActions, canonicalIndex, isOffline);
const shouldDisableContextMenuForConciergeDraft = isDraftPendingCompletion && draftReportActionID === reportAction.reportActionID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ type UseMoneyRequestReportVisibleActionsParams = {
/** Whether the current user can perform write actions on the report */
canPerformWriteAction: boolean;

/** Whether the harvest-created expense CREATED action should stay visible */
shouldShowHarvestCreatedAction: boolean;
/** Keeps creation history visible for harvested expense reports, bills, and invoices linked to bills. */
shouldShowCreatedAction: boolean;

/** Whether the network is offline */
isOffline: boolean;
Expand Down Expand Up @@ -66,15 +66,15 @@ function useMoneyRequestReportVisibleActions({
reportActions,
reportTransactionIDs,
canPerformWriteAction,
shouldShowHarvestCreatedAction,
shouldShowCreatedAction,
isOffline,
isWaitingOnBankAccount = false,
}: UseMoneyRequestReportVisibleActionsParams): UseMoneyRequestReportVisibleActionsResult {
const [visibleReportActionsData] = useOnyx(ONYXKEYS.DERIVED.VISIBLE_REPORT_ACTIONS, {selector: reportVisibleActionsSelector(reportID)});

const reportActionsWithVisiblePayments = isWaitingOnBankAccount ? reportActions.filter((action) => !shouldHidePayAction(action, true)) : reportActions;
const visibleReportActionsNewestFirst = reportActionsWithVisiblePayments.filter((reportAction) => {
const isActionVisibleOnMoneyReport = isActionVisibleOnMoneyRequestReport(reportAction, shouldShowHarvestCreatedAction);
const isActionVisibleOnMoneyReport = isActionVisibleOnMoneyRequestReport(reportAction, shouldShowCreatedAction);
if (!isActionVisibleOnMoneyReport) {
return false;
}
Expand Down
26 changes: 24 additions & 2 deletions src/components/ReportActionAvatars/useReportActionAvatars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {useAllPersonalDetails} from '@hooks/usePersonalDetails';
import usePolicy from '@hooks/usePolicy';
import useReportIsArchived from '@hooks/useReportIsArchived';

import {isBillPayHistoryAction} from '@libs/BillPayReportActionUtils';
import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
import {
getDelegateAccountIDFromReportAction,
Expand Down Expand Up @@ -34,8 +35,9 @@ import {buildUserIcon} from '@libs/UserAvatarUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import {getStableReportSelector} from '@src/selectors/Report';
import {getReportActionByIDSelector} from '@src/selectors/ReportAction';
import {getBillProcessorAccountIDSelector, getReportActionByIDSelector} from '@src/selectors/ReportAction';
import {pendingDeleteMemberAccountIDsSelector} from '@src/selectors/ReportMetaData';
import {isLinkedToBillSelector} from '@src/selectors/ReportNameValuePairs';
import type {InvitedEmailsToAccountIDs, OnyxInputOrEntry, Policy, Report, ReportAction} from '@src/types/onyx';
import type {Icon as IconType} from '@src/types/onyx/OnyxCommon';

Expand Down Expand Up @@ -134,7 +136,21 @@ function useReportActionAvatars({

const delegateAccountID = getDelegateAccountIDFromReportAction(action);
const delegatePersonalDetails = delegateAccountID ? personalDetails?.[delegateAccountID] : undefined;
const actorAccountID = getReportActionActorAccountID(action, iouReport, chatReport, delegatePersonalDetails, shouldUseRealActor);
const [isInvoiceLinkedToBill = false] = useOnyx(
`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${getNonEmptyStringOnyxID(isInvoiceReport(iouReport) ? iouReport?.reportID : undefined)}`,
{
selector: isLinkedToBillSelector,
},
);
const isBillPayHistory = isBillPayHistoryAction(action, iouReport, isInvoiceLinkedToBill);
const [billProcessorAccountID] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getNonEmptyStringOnyxID(isBillPayHistory ? iouReport?.reportID : undefined)}`, {
selector: getBillProcessorAccountIDSelector,
});

const actorAccountID = getReportActionActorAccountID(action, iouReport, chatReport, delegatePersonalDetails, shouldUseRealActor, {
isInvoiceLinkedToBill,
processorAccountID: billProcessorAccountID,
});
const humanAgentAccountID = getHumanAgentAccountIDFromReportAction(action);

const isAInvoiceReport = isInvoiceReport(iouReport ?? null);
Expand Down Expand Up @@ -363,6 +379,12 @@ function useReportActionAvatars({
avatars = [firstAvatar, policyChatReportIcon];
}

// Intake history credits Concierge even when personal details are missing or still use the account's email as its name.
if (isBillPayHistory && actorAccountID === CONST.ACCOUNT_ID.CONCIERGE) {
avatars = [{id: actorAccountID, type: CONST.ICON_TYPE_AVATAR, source: defaultAvatars.ConciergeAvatar, name: CONST.CONCIERGE_DISPLAY_NAME}];
avatarType = CONST.REPORT_ACTION_AVATARS.TYPE.SINGLE;
}

// When a human Concierge agent reveals themselves, show a subscript avatar
// with Concierge as the main avatar and the agent as the secondary avatar
if (humanAgentAccountID && avatarType === CONST.REPORT_ACTION_AVATARS.TYPE.SINGLE) {
Expand Down
6 changes: 6 additions & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ type StateValue = {
type States = Record<keyof typeof COMMON_CONST.STATES, StateValue>;
type AllCountries = Record<Country, string>;
const translations: TranslationDeepObject<typeof en> = {
billPay: {
billCreated: ({sender}) => `hat diese Rechnung im Namen von ${sender} erstellt`,
billSubmitted: ({receiver}) => `hat diese Rechnung an ${receiver} gesendet`,
invoiceCreated: ({sender}) => `hat diese Rechnung im Namen von ${sender} erstellt`,
invoiceSubmitted: ({receiver}) => `hat diese Rechnung an ${receiver} gesendet`,
},
common: {
durationDays: ({count}: {count: number}) => ({
one: `1 Tag`,
Expand Down
6 changes: 6 additions & 0 deletions src/languages/el.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ type StateValue = {
type States = Record<keyof typeof COMMON_CONST.STATES, StateValue>;
type AllCountries = Record<Country, string>;
const translations: TranslationDeepObject<typeof en> = {
billPay: {
billCreated: ({sender}) => `δημιούργησε αυτόν τον λογαριασμό εκ μέρους του ${sender}`,
billSubmitted: ({receiver}) => `έστειλε αυτόν τον λογαριασμό στον ${receiver}`,
invoiceCreated: ({sender}) => `δημιούργησε αυτό το τιμολόγιο εκ μέρους του ${sender}`,
invoiceSubmitted: ({receiver}) => `έστειλε αυτό το τιμολόγιο στον ${receiver}`,
},
common: {
durationDays: ({count}: {count: number}) => ({
one: `1 ημέρα`,
Expand Down
6 changes: 6 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ type States = Record<keyof typeof COMMON_CONST.STATES, StateValue>;
type AllCountries = Record<Country, string>;

const translations = {
billPay: {
billCreated: ({sender}: {sender: string}) => `created this bill on behalf of ${sender}`,
billSubmitted: ({receiver}: {receiver: string}) => `sent this bill to ${receiver}`,
invoiceCreated: ({sender}: {sender: string}) => `created this invoice on behalf of ${sender}`,
invoiceSubmitted: ({receiver}: {receiver: string}) => `sent this invoice to ${receiver}`,
},
bulkActionBar: {
label: 'Bulk actions',
clearSelection: 'Clear selection',
Expand Down
6 changes: 6 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ import type {CompanyCardBalanceParams} from './params';
import type {AllConnectionName, PolicyConnectionSyncStage} from './TranslationTypes';
import type {TranslationDeepObject} from './types';
const translations: TranslationDeepObject<typeof en> = {
billPay: {
billCreated: ({sender}) => `creó esta factura en nombre de ${sender}`,
billSubmitted: ({receiver}) => `envió esta factura a ${receiver}`,
invoiceCreated: ({sender}) => `creó esta factura en nombre de ${sender}`,
invoiceSubmitted: ({receiver}) => `envió esta factura a ${receiver}`,
},
common: {
durationDays: ({count}: {count: number}) => ({
one: `1 día`,
Expand Down
6 changes: 6 additions & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ type StateValue = {
type States = Record<keyof typeof COMMON_CONST.STATES, StateValue>;
type AllCountries = Record<Country, string>;
const translations: TranslationDeepObject<typeof en> = {
billPay: {
billCreated: ({sender}) => `a créé cette facture au nom de ${sender}`,
billSubmitted: ({receiver}) => `a envoyé cette facture à ${receiver}`,
invoiceCreated: ({sender}) => `a créé cette facture au nom de ${sender}`,
invoiceSubmitted: ({receiver}) => `a envoyé cette facture à ${receiver}`,
},
common: {
durationDays: ({count}: {count: number}) => ({
one: `${count} jour`,
Expand Down
6 changes: 6 additions & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ type StateValue = {
type States = Record<keyof typeof COMMON_CONST.STATES, StateValue>;
type AllCountries = Record<Country, string>;
const translations: TranslationDeepObject<typeof en> = {
billPay: {
billCreated: ({sender}) => `ha creato questa fattura per conto di ${sender}`,
billSubmitted: ({receiver}) => `ha inviato questa fattura a ${receiver}`,
invoiceCreated: ({sender}) => `ha creato questa fattura per conto di ${sender}`,
invoiceSubmitted: ({receiver}) => `ha inviato questa fattura a ${receiver}`,
},
common: {
durationDays: ({count}: {count: number}) => ({
one: `1 giorno`,
Expand Down
6 changes: 6 additions & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ type StateValue = {
type States = Record<keyof typeof COMMON_CONST.STATES, StateValue>;
type AllCountries = Record<Country, string>;
const translations: TranslationDeepObject<typeof en> = {
billPay: {
billCreated: ({sender}) => `${sender} に代わってこの請求書を作成しました`,
billSubmitted: ({receiver}) => `この請求書を ${receiver} に送信しました`,
invoiceCreated: ({sender}) => `${sender} に代わってこの請求書を作成しました`,
invoiceSubmitted: ({receiver}) => `この請求書を ${receiver} に送信しました`,
},
common: {
durationDays: ({count}: {count: number}) => ({
one: `1 日`,
Expand Down
6 changes: 6 additions & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ type StateValue = {
type States = Record<keyof typeof COMMON_CONST.STATES, StateValue>;
type AllCountries = Record<Country, string>;
const translations: TranslationDeepObject<typeof en> = {
billPay: {
billCreated: ({sender}) => `heeft deze factuur aangemaakt namens ${sender}`,
billSubmitted: ({receiver}) => `heeft deze factuur verzonden naar ${receiver}`,
invoiceCreated: ({sender}) => `heeft deze factuur aangemaakt namens ${sender}`,
invoiceSubmitted: ({receiver}) => `heeft deze factuur verzonden naar ${receiver}`,
},
common: {
durationDays: ({count}: {count: number}) => ({
one: `1 dag`,
Expand Down
6 changes: 6 additions & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ type StateValue = {
type States = Record<keyof typeof COMMON_CONST.STATES, StateValue>;
type AllCountries = Record<Country, string>;
const translations: TranslationDeepObject<typeof en> = {
billPay: {
billCreated: ({sender}) => `utworzono ten rachunek w imieniu ${sender}`,
billSubmitted: ({receiver}) => `wysłano ten rachunek do ${receiver}`,
invoiceCreated: ({sender}) => `utworzono tę fakturę w imieniu ${sender}`,
invoiceSubmitted: ({receiver}) => `wysłano tę fakturę do ${receiver}`,
},
common: {
durationDays: ({count}: {count: number}) => ({
one: `1 dzień`,
Expand Down
6 changes: 6 additions & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ type StateValue = {
type States = Record<keyof typeof COMMON_CONST.STATES, StateValue>;
type AllCountries = Record<Country, string>;
const translations: TranslationDeepObject<typeof en> = {
billPay: {
billCreated: ({sender}) => `criou esta conta em nome de ${sender}`,
billSubmitted: ({receiver}) => `enviou esta conta para ${receiver}`,
invoiceCreated: ({sender}) => `criou esta fatura em nome de ${sender}`,
invoiceSubmitted: ({receiver}) => `enviou esta fatura para ${receiver}`,
},
common: {
durationDays: ({count}: {count: number}) => ({
one: `${count} dia`,
Expand Down
6 changes: 6 additions & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ type StateValue = {
type States = Record<keyof typeof COMMON_CONST.STATES, StateValue>;
type AllCountries = Record<Country, string>;
const translations: TranslationDeepObject<typeof en> = {
billPay: {
billCreated: ({sender}) => `代表 ${sender} 创建了此账单`,
billSubmitted: ({receiver}) => `将此账单发送给 ${receiver}`,
invoiceCreated: ({sender}) => `代表 ${sender} 创建了此发票`,
invoiceSubmitted: ({receiver}) => `将此发票发送给 ${receiver}`,
},
common: {
durationDays: ({count}: {count: number}) => ({
one: `1 天`,
Expand Down
28 changes: 28 additions & 0 deletions src/libs/BillPayReportActionUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/** Bill intake records creation and submission under the vendor or receiver rather than the person who created the bill. */
import CONST from '@src/CONST';
import type {Report, ReportAction} from '@src/types/onyx';

import type {OnyxEntry} from 'react-native-onyx';

function isBillPayReport(report: OnyxEntry<Report>, isInvoiceLinkedToBill: boolean): boolean {
return report?.type === CONST.REPORT.UNSUPPORTED_TYPE.BILL || (report?.type === CONST.REPORT.TYPE.INVOICE && isInvoiceLinkedToBill);
}

function isBillPayHistoryAction(action: OnyxEntry<ReportAction>, report: OnyxEntry<Report>, isInvoiceLinkedToBill: boolean): boolean {
if (
action?.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED &&
action?.actionName !== CONST.REPORT.ACTIONS.TYPE.SUBMITTED &&
action?.actionName !== CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED
) {
return false;
}
return isBillPayReport(report, isInvoiceLinkedToBill);
}

// Bill Pay history replaces the stored creation and submission actors.
// Keep separate actor headers for these actions and the actions immediately before and after them.
function shouldKeepBillPayActorHeader(action: OnyxEntry<ReportAction>, previousAction: OnyxEntry<ReportAction>, report: OnyxEntry<Report>, isInvoiceLinkedToBill: boolean): boolean {
return isBillPayHistoryAction(action, report, isInvoiceLinkedToBill) || isBillPayHistoryAction(previousAction, report, isInvoiceLinkedToBill);
}

export {isBillPayHistoryAction, isBillPayReport, shouldKeepBillPayActorHeader};
Loading
Loading