Skip to content

Commit

Permalink
Merge branch 'main' into fix/34915
Browse files Browse the repository at this point in the history
  • Loading branch information
dukenv0307 committed Jan 29, 2024
2 parents f1ab769 + a614bfb commit 9eca9d5
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Concierge Receipt Audit is a real-time audit and compliance of receipts submitte

- To make sure you don't miss any risky expenses that need human oversight.
- To avoid needing to manually review all your company receipts.
- It's included for free with the [Control Plan](https://www.expensify.com/pricing).
- It's included at no extra cost with the [Control Plan](https://www.expensify.com/pricing).
- Instead of paying someone to audit your company expenses or being concerned that your expenses might be audited by a government agency.
- It's easy to use! Concierge will alert you to the risky expense and present it to you in an easy-to-follow review tutorial.
- In addition to the risky expense alerts, Expensify will include a Note with audit details on every report.
Expand Down
1 change: 1 addition & 0 deletions docs/redirects.csv
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ https://community.expensify.com/discussion/5124/how-to-add-your-name-and-photo-t
https://community.expensify.com/discussion/5149/how-to-manage-your-devices-in-expensify,https://help.expensify.com/articles/expensify-classic/account-settings/Account-Details
https://community.expensify.com/discussion/4432/how-to-add-a-secondary-login,https://help.expensify.com/articles/expensify-classic/account-settings/Account-Details
https://community.expensify.com/discussion/6794/how-to-change-your-email-in-expensify,https://help.expensify.com/articles/expensify-classic/account-settings/Account-Details
https://help.expensify.com/articles/expensify-classic/getting-started/approved-accountants/Card-Revenue-Share-For-Expensify-Approved-Partners, https://use.expensify.com/blog/maximizing-rewards-expensifyapproved-accounting-partners-now-earn-0-5-revenue-share
1 change: 0 additions & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,6 @@ const CONST = {
ROOMCHANGELOG: {
INVITE_TO_ROOM: 'INVITETOROOM',
REMOVE_FROM_ROOM: 'REMOVEFROMROOM',
JOIN_ROOM: 'JOINROOM',
},
},
THREAD_DISABLED: ['CREATED'],
Expand Down
10 changes: 5 additions & 5 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function MoneyReportHeader({session, personalDetails, policy, chatReport, nextSt
const styles = useThemeStyles();
const {translate} = useLocalize();
const {windowWidth, isSmallScreenWidth} = useWindowDimensions();
const reimbursableTotal = ReportUtils.getMoneyRequestReimbursableTotal(moneyRequestReport);
const {reimbursableSpend} = ReportUtils.getMoneyRequestSpendBreakdown(moneyRequestReport);
const isApproved = ReportUtils.isReportApproved(moneyRequestReport);
const isSettled = ReportUtils.isSettled(moneyRequestReport.reportID);
const policyType = policy?.type;
Expand All @@ -66,8 +66,8 @@ function MoneyReportHeader({session, personalDetails, policy, chatReport, nextSt
: isPolicyAdmin || (ReportUtils.isMoneyRequestReport(moneyRequestReport) && isManager);
const isDraft = ReportUtils.isDraftExpenseReport(moneyRequestReport);
const shouldShowPayButton = useMemo(
() => isPayer && !isDraft && !isSettled && !moneyRequestReport.isWaitingOnBankAccount && reimbursableTotal !== 0 && !ReportUtils.isArchivedRoom(chatReport) && !isAutoReimbursable,
[isPayer, isDraft, isSettled, moneyRequestReport, reimbursableTotal, chatReport, isAutoReimbursable],
() => isPayer && !isDraft && !isSettled && !moneyRequestReport.isWaitingOnBankAccount && reimbursableSpend !== 0 && !ReportUtils.isArchivedRoom(chatReport) && !isAutoReimbursable,
[isPayer, isDraft, isSettled, moneyRequestReport, reimbursableSpend, chatReport, isAutoReimbursable],
);
const shouldShowApproveButton = useMemo(() => {
if (!isPaidGroupPolicy) {
Expand All @@ -76,12 +76,12 @@ function MoneyReportHeader({session, personalDetails, policy, chatReport, nextSt
return isManager && !isDraft && !isApproved && !isSettled;
}, [isPaidGroupPolicy, isManager, isDraft, isApproved, isSettled]);
const shouldShowSettlementButton = shouldShowPayButton || shouldShowApproveButton;
const shouldShowSubmitButton = isDraft && reimbursableTotal !== 0;
const shouldShowSubmitButton = isDraft && reimbursableSpend !== 0;
const isFromPaidPolicy = policyType === CONST.POLICY.TYPE.TEAM || policyType === CONST.POLICY.TYPE.CORPORATE;
const shouldShowNextStep = isFromPaidPolicy && !!nextStep?.message?.length;
const shouldShowAnyButton = shouldShowSettlementButton || shouldShowApproveButton || shouldShowSubmitButton || shouldShowNextStep;
const bankAccountRoute = ReportUtils.getBankAccountRoute(chatReport);
const formattedAmount = CurrencyUtils.convertToDisplayString(reimbursableTotal, moneyRequestReport.currency);
const formattedAmount = CurrencyUtils.convertToDisplayString(reimbursableSpend, moneyRequestReport.currency);
const isMoreContentShown = shouldShowNextStep || (shouldShowAnyButton && isSmallScreenWidth);

// The submit button should be success green colour only if the user is submitter and the policy does not have Scheduled Submit turned on
Expand Down
5 changes: 5 additions & 0 deletions src/components/ReportActionItem/MoneyRequestAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ const propTypes = {
/** The ID of the associated request report */
requestReportID: PropTypes.string.isRequired,

/** The ID of the current report */
reportID: PropTypes.string.isRequired,

/** Is this IOUACTION the most recent? */
isMostRecentIOUReportAction: PropTypes.bool.isRequired,

Expand Down Expand Up @@ -81,6 +84,7 @@ function MoneyRequestAction({
action,
chatReportID,
requestReportID,
reportID,
isMostRecentIOUReportAction,
contextMenuAnchor,
checkIfContextMenuActive,
Expand Down Expand Up @@ -136,6 +140,7 @@ function MoneyRequestAction({
<MoneyRequestPreview
iouReportID={requestReportID}
chatReportID={chatReportID}
reportID={reportID}
isBillSplit={isSplitBillAction}
action={action}
contextMenuAnchor={contextMenuAnchor}
Expand Down
5 changes: 4 additions & 1 deletion src/components/ReportActionItem/MoneyRequestPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const propTypes = {
/** The associated chatReport */
chatReportID: PropTypes.string.isRequired,

/** The ID of the current report */
reportID: PropTypes.string.isRequired,

/** Callback for the preview pressed */
onPreviewPressed: PropTypes.func,

Expand Down Expand Up @@ -188,7 +191,7 @@ function MoneyRequestPreview(props) {
};

const showContextMenu = (event) => {
showContextMenuForReport(event, props.contextMenuAnchor, props.chatReportID, props.action, props.checkIfContextMenuActive);
showContextMenuForReport(event, props.contextMenuAnchor, props.reportID, props.action, props.checkIfContextMenuActive);
};

const getPreviewHeaderText = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ function createOption(
}

result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result);
result.iouReportAmount = ReportUtils.getMoneyRequestReimbursableTotal(result);
result.iouReportAmount = ReportUtils.getMoneyRequestSpendBreakdown(result).totalDisplaySpend;

if (!hasMultipleParticipants) {
result.login = personalDetail?.login;
Expand Down
31 changes: 4 additions & 27 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1794,28 +1794,6 @@ function hasNonReimbursableTransactions(iouReportID: string | undefined): boolea
return transactions.filter((transaction) => transaction.reimbursable === false).length > 0;
}

function getMoneyRequestReimbursableTotal(report: OnyxEntry<Report>, allReportsDict: OnyxCollection<Report> = null): number {
const allAvailableReports = allReportsDict ?? allReports;
let moneyRequestReport: OnyxEntry<Report> | undefined;
if (isMoneyRequestReport(report)) {
moneyRequestReport = report;
}
if (allAvailableReports && report?.iouReportID) {
moneyRequestReport = allAvailableReports[`${ONYXKEYS.COLLECTION.REPORT}${report.iouReportID}`];
}
if (moneyRequestReport) {
const total = moneyRequestReport?.total ?? 0;

if (total !== 0) {
// There is a possibility that if the Expense report has a negative total.
// This is because there are instances where you can get a credit back on your card,
// or you enter a negative expense to “offset” future expenses
return isExpenseReport(moneyRequestReport) ? total * -1 : Math.abs(total);
}
}
return 0;
}

function getMoneyRequestSpendBreakdown(report: OnyxEntry<Report>, allReportsDict: OnyxCollection<Report> = null): SpendBreakdown {
const allAvailableReports = allReportsDict ?? allReports;
let moneyRequestReport;
Expand Down Expand Up @@ -1896,7 +1874,7 @@ function getPolicyExpenseChatName(report: OnyxEntry<Report>, policy: OnyxEntry<P
* Get the title for an IOU or expense chat which will be showing the payer and the amount
*/
function getMoneyRequestReportName(report: OnyxEntry<Report>, policy: OnyxEntry<Policy> | undefined = undefined): string {
const moneyRequestTotal = getMoneyRequestReimbursableTotal(report);
const moneyRequestTotal = getMoneyRequestSpendBreakdown(report).totalDisplaySpend;
const formattedAmount = CurrencyUtils.convertToDisplayString(moneyRequestTotal, report?.currency, hasOnlyDistanceRequestTransactions(report?.reportID));
const payerOrApproverName = isExpenseReport(report) ? getPolicyName(report, false, policy) : getDisplayNameForParticipant(report?.managerID) ?? '';
const payerPaidAmountMessage = Localize.translateLocal('iou.payerPaidAmount', {
Expand Down Expand Up @@ -2196,7 +2174,7 @@ function getReportPreviewMessage(
}
}

const totalAmount = getMoneyRequestReimbursableTotal(report);
const totalAmount = getMoneyRequestSpendBreakdown(report).totalDisplaySpend;
const policyName = getPolicyName(report, false, policy);
const payerName = isExpenseReport(report) ? policyName : getDisplayNameForParticipant(report.managerID, !isPreviewMessageForParentChatReport);

Expand Down Expand Up @@ -2791,7 +2769,7 @@ function getIOUReportActionMessage(iouReportID: string, type: string, total: num
const report = getReport(iouReportID);
const amount =
type === CONST.IOU.REPORT_ACTION_TYPE.PAY
? CurrencyUtils.convertToDisplayString(getMoneyRequestReimbursableTotal(!isEmptyObject(report) ? report : null), currency)
? CurrencyUtils.convertToDisplayString(getMoneyRequestSpendBreakdown(!isEmptyObject(report) ? report : null).totalDisplaySpend, currency)
: CurrencyUtils.convertToDisplayString(total, currency);

let paymentMethodMessage;
Expand Down Expand Up @@ -4645,7 +4623,7 @@ function canBeAutoReimbursed(report: OnyxEntry<Report>, policy: OnyxEntry<Policy
return false;
}
type CurrencyType = (typeof CONST.DIRECT_REIMBURSEMENT_CURRENCIES)[number];
const reimbursableTotal = getMoneyRequestReimbursableTotal(report);
const reimbursableTotal = getMoneyRequestSpendBreakdown(report).totalDisplaySpend;
const autoReimbursementLimit = policy.autoReimbursementLimit ?? 0;
const isAutoReimbursable =
isGroupPolicy(report) &&
Expand Down Expand Up @@ -4692,7 +4670,6 @@ export {
hasExpensifyGuidesEmails,
requiresAttentionFromCurrentUser,
isIOUOwnedByCurrentUser,
getMoneyRequestReimbursableTotal,
getMoneyRequestSpendBreakdown,
canShowReportRecipientLocalTime,
formatReportLastMessageText,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function getOrderedReportIDs(
report.displayName = ReportUtils.getReportName(report);

// eslint-disable-next-line no-param-reassign
report.iouReportAmount = ReportUtils.getMoneyRequestReimbursableTotal(report, allReports);
report.iouReportAmount = ReportUtils.getMoneyRequestSpendBreakdown(report, allReports).totalDisplaySpend;

const isPinned = report.isPinned ?? false;
const reportAction = ReportActionsUtils.getReportAction(report.parentReportID ?? '', report.parentReportActionID ?? '');
Expand Down Expand Up @@ -459,7 +459,7 @@ function getOptionData({
}

result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result as Report);
result.iouReportAmount = ReportUtils.getMoneyRequestReimbursableTotal(result as Report);
result.iouReportAmount = ReportUtils.getMoneyRequestSpendBreakdown(result as Report).totalDisplaySpend;

if (!hasMultipleParticipants) {
result.accountID = personalDetail?.accountID;
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ function ReportActionItem(props) {
// If originalMessage.iouReportID is set, this is a 1:1 money request in a DM chat whose reportID is props.report.chatReportID
chatReportID={originalMessage.IOUReportID ? props.report.chatReportID : props.report.reportID}
requestReportID={iouReportID}
reportID={props.report.reportID}
action={props.action}
isMostRecentIOUReportAction={props.isMostRecentIOUReportAction}
isHovered={hovered}
Expand Down

0 comments on commit 9eca9d5

Please sign in to comment.