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
2 changes: 2 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6690,6 +6690,7 @@ const CONST = {
DATE: this.TABLE_COLUMNS.DATE,
SUBMITTED: this.TABLE_COLUMNS.SUBMITTED,
APPROVED: this.TABLE_COLUMNS.APPROVED,
POSTED: this.TABLE_COLUMNS.POSTED,
MERCHANT: this.TABLE_COLUMNS.MERCHANT,
FROM: this.TABLE_COLUMNS.FROM,
TO: this.TABLE_COLUMNS.TO,
Expand Down Expand Up @@ -6781,6 +6782,7 @@ const CONST = {
DATE: 'date',
SUBMITTED: 'submitted',
APPROVED: 'approved',
POSTED: 'posted',
MERCHANT: 'merchant',
DESCRIPTION: 'description',
FROM: 'from',
Expand Down
3 changes: 2 additions & 1 deletion src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ function Search({
navigation.setParams({q: newQuery, rawQuery: undefined});
};

const {shouldShowYearCreated, shouldShowYearSubmitted, shouldShowYearApproved} = shouldShowYearUtil(searchResults?.data, isExpenseReportType ?? false);
const {shouldShowYearCreated, shouldShowYearSubmitted, shouldShowYearApproved, shouldShowYearPosted} = shouldShowYearUtil(searchResults?.data, isExpenseReportType ?? false);
const {shouldShowAmountInWideColumn, shouldShowTaxAmountInWideColumn} = getWideAmountIndicators(searchResults?.data);
const shouldShowSorting = !validGroupBy;
const shouldShowTableHeader = isLargeScreenWidth && !isChat && !validGroupBy;
Expand Down Expand Up @@ -1074,6 +1074,7 @@ function Search({
shouldShowYear={shouldShowYearCreated}
shouldShowYearSubmitted={shouldShowYearSubmitted}
shouldShowYearApproved={shouldShowYearApproved}
shouldShowYearPosted={shouldShowYearPosted}
isAmountColumnWide={shouldShowAmountInWideColumn}
isTaxAmountColumnWide={shouldShowTaxAmountInWideColumn}
shouldShowSorting={shouldShowSorting}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,22 @@ function TransactionListItem<TItem extends ListItem>({
backgroundColor: theme.highlightBG,
});

const {amountColumnSize, dateColumnSize, taxAmountColumnSize, submittedColumnSize, approvedColumnSize} = useMemo(() => {
const {amountColumnSize, dateColumnSize, taxAmountColumnSize, submittedColumnSize, approvedColumnSize, postedColumnSize} = useMemo(() => {
return {
amountColumnSize: transactionItem.isAmountColumnWide ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL,
taxAmountColumnSize: transactionItem.isTaxAmountColumnWide ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL,
dateColumnSize: transactionItem.shouldShowYear ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL,
submittedColumnSize: transactionItem.shouldShowYearSubmitted ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL,
approvedColumnSize: transactionItem.shouldShowYearApproved ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL,
postedColumnSize: transactionItem.shouldShowYearPosted ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL,
};
}, [
transactionItem.isAmountColumnWide,
transactionItem.isTaxAmountColumnWide,
transactionItem.shouldShowYear,
transactionItem.shouldShowYearSubmitted,
transactionItem.shouldShowYearApproved,
transactionItem.shouldShowYearPosted,
]);

const transactionViolations = useMemo(() => {
Expand Down Expand Up @@ -193,6 +195,7 @@ function TransactionListItem<TItem extends ListItem>({
dateColumnSize={dateColumnSize}
submittedColumnSize={submittedColumnSize}
approvedColumnSize={approvedColumnSize}
postedColumnSize={postedColumnSize}
amountColumnSize={amountColumnSize}
taxAmountColumnSize={taxAmountColumnSize}
shouldShowCheckbox={!!canSelectMultiple}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ const getExpenseHeaders = (groupBy?: SearchGroupBy): SearchColumnConfig[] => [
columnName: CONST.SEARCH.TABLE_COLUMNS.APPROVED,
translationKey: 'search.filters.approved',
},
{
columnName: CONST.SEARCH.TABLE_COLUMNS.POSTED,
translationKey: 'search.filters.posted',
},
{
columnName: CONST.SEARCH.TABLE_COLUMNS.MERCHANT,
translationKey: 'common.merchant',
Expand Down Expand Up @@ -215,6 +219,7 @@ type SearchTableHeaderProps = {
shouldShowYear: boolean;
shouldShowYearSubmitted?: boolean;
shouldShowYearApproved?: boolean;
shouldShowYearPosted?: boolean;
isAmountColumnWide: boolean;
isTaxAmountColumnWide: boolean;
shouldShowSorting: boolean;
Expand All @@ -232,6 +237,7 @@ function SearchTableHeader({
shouldShowYear,
shouldShowYearSubmitted,
shouldShowYearApproved,
shouldShowYearPosted,
shouldShowSorting,
canSelectMultiple,
isAmountColumnWide,
Expand Down Expand Up @@ -272,6 +278,7 @@ function SearchTableHeader({
dateColumnSize={shouldShowYear ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL}
submittedColumnSize={shouldShowYearSubmitted ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL}
approvedColumnSize={shouldShowYearApproved ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL}
postedColumnSize={shouldShowYearPosted ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL}
amountColumnSize={isAmountColumnWide ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL}
taxAmountColumnSize={isTaxAmountColumnWide ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL}
shouldShowSorting={shouldShowSorting}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type SearchTableHeaderProps = {
dateColumnSize: TableColumnSize;
submittedColumnSize?: TableColumnSize;
approvedColumnSize?: TableColumnSize;
postedColumnSize?: TableColumnSize;
amountColumnSize: TableColumnSize;
taxAmountColumnSize: TableColumnSize;
containerStyles?: StyleProp<ViewStyle>;
Expand All @@ -43,6 +44,7 @@ function SortableTableHeader({
dateColumnSize,
submittedColumnSize,
approvedColumnSize,
postedColumnSize,
containerStyles,
shouldShowSorting,
onSortPress,
Expand Down Expand Up @@ -83,6 +85,7 @@ function SortableTableHeader({
!!areAllOptionalColumnsHidden,
submittedColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE,
approvedColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE,
postedColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE,
),
]}
isSortable={isSortable}
Expand Down
8 changes: 8 additions & 0 deletions src/components/SelectionListWithSections/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ type TransactionListItemType = ListItem &
/** The date the report was approved */
approved?: string;

/** The date the report was posted */
posted?: string;

/** Policy to which the transaction belongs */
policy: Policy | undefined;

Expand Down Expand Up @@ -297,6 +300,11 @@ type TransactionListItemType = ListItem &
*/
shouldShowYearApproved: boolean;

/** Whether we should show the year for the posted date.
* This is true if at least one transaction in the dataset was posted in past years
*/
shouldShowYearPosted: boolean;

isAmountColumnWide: boolean;

isTaxAmountColumnWide: boolean;
Expand Down
16 changes: 16 additions & 0 deletions src/components/TransactionItemRow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ type TransactionItemRowProps = {
dateColumnSize: TableColumnSize;
submittedColumnSize?: TableColumnSize;
approvedColumnSize?: TableColumnSize;
postedColumnSize?: TableColumnSize;
amountColumnSize: TableColumnSize;
taxAmountColumnSize: TableColumnSize;
onCheckboxPress?: (transactionID: string) => void;
Expand Down Expand Up @@ -136,6 +137,7 @@ function TransactionItemRow({
dateColumnSize,
submittedColumnSize,
approvedColumnSize,
postedColumnSize,
amountColumnSize,
taxAmountColumnSize,
onCheckboxPress = () => {},
Expand Down Expand Up @@ -169,6 +171,7 @@ function TransactionItemRow({
const isDateColumnWide = dateColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE;
const isSubmittedColumnWide = submittedColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE;
const isApprovedColumnWide = approvedColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE;
const isPostedColumnWide = postedColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE;
const isAmountColumnWide = amountColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE;
const isTaxAmountColumnWide = taxAmountColumnSize === CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE;

Expand Down Expand Up @@ -284,6 +287,18 @@ function TransactionItemRow({
/>
</View>
),
[CONST.SEARCH.TABLE_COLUMNS.POSTED]: (
<View
key={CONST.SEARCH.TABLE_COLUMNS.POSTED}
style={[StyleUtils.getReportTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.POSTED, false, false, false, areAllOptionalColumnsHidden, false, false, isPostedColumnWide)]}
>
<DateCell
date={transactionItem.posted ?? ''}
showTooltip={shouldShowTooltip}
isLargeScreenWidth={!shouldUseNarrowLayout}
/>
</View>
),
[CONST.SEARCH.TABLE_COLUMNS.CATEGORY]: (
<View
key={CONST.SEARCH.TABLE_COLUMNS.CATEGORY}
Expand Down Expand Up @@ -427,6 +442,7 @@ function TransactionItemRow({
isDateColumnWide,
isSubmittedColumnWide,
isApprovedColumnWide,
isPostedColumnWide,
isAmountColumnWide,
isTaxAmountColumnWide,
isInSingleTransactionReport,
Expand Down
38 changes: 32 additions & 6 deletions src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ const transactionColumnNamesToSortingProperty: TransactionSorting = {
[CONST.SEARCH.TABLE_COLUMNS.DATE]: 'date' as const,
[CONST.SEARCH.TABLE_COLUMNS.SUBMITTED]: 'submitted' as const,
[CONST.SEARCH.TABLE_COLUMNS.APPROVED]: 'approved' as const,
[CONST.SEARCH.TABLE_COLUMNS.POSTED]: 'posted' as const,
[CONST.SEARCH.TABLE_COLUMNS.TAG]: 'tag' as const,
[CONST.SEARCH.TABLE_COLUMNS.MERCHANT]: 'formattedMerchant' as const,
[CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]: 'formattedTotal' as const,
Expand Down Expand Up @@ -649,7 +650,7 @@ function getTransactionItemCommonFormattedProperties(
policy: OnyxTypes.Policy,
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'],
report: OnyxTypes.Report | undefined,
): Pick<TransactionListItemType, 'formattedFrom' | 'formattedTo' | 'formattedTotal' | 'formattedMerchant' | 'date' | 'submitted' | 'approved'> {
): Pick<TransactionListItemType, 'formattedFrom' | 'formattedTo' | 'formattedTotal' | 'formattedMerchant' | 'date' | 'submitted' | 'approved' | 'posted'> {
const isExpenseReport = report?.type === CONST.REPORT.TYPE.EXPENSE;

const fromName = getDisplayNameOrDefault(from);
Expand All @@ -670,12 +671,16 @@ function getTransactionItemCommonFormattedProperties(
const submitted = report?.submitted;
const approved = report?.approved;

// Posted date is in the YYYYMMDD format, so we format it to YYYY-MM-DD here since JS's Date constructor interprets it as an invalid date.
const posted = !transactionItem?.posted ? '' : `${transactionItem?.posted.slice(0, 4)}-${transactionItem?.posted.slice(4, 6)}-${transactionItem?.posted.slice(6, 8)}`;

return {
formattedFrom,
formattedTo,
date,
submitted,
approved,
posted,
formattedTotal,
formattedMerchant,
};
Expand Down Expand Up @@ -858,6 +863,7 @@ type ShouldShowYearResult = {
shouldShowYearCreated: boolean;
shouldShowYearSubmitted: boolean;
shouldShowYearApproved: boolean;
shouldShowYearPosted: boolean;
};

/**
Expand All @@ -874,6 +880,7 @@ function shouldShowYear(
shouldShowYearCreated: false,
shouldShowYearSubmitted: false,
shouldShowYearApproved: false,
shouldShowYearPosted: false,
};

const currentYear = new Date().getFullYear();
Expand Down Expand Up @@ -908,10 +915,16 @@ function shouldShowYear(
if (item.approved && DateUtils.doesDateBelongToAPastYear(item.approved)) {
result.shouldShowYearApproved = true;
}

// Posted date is in the YYYYMMDD format, so we extract the year manually here since JS's Date constructor interprets it as an invalid date.
if (item?.posted) {
Comment thread
luacmartins marked this conversation as resolved.
const postedYear = parseInt(item.posted.slice(0, 4), 10);
result.shouldShowYearPosted = postedYear !== currentYear;
}
}

// Early exit if all flags are true
if (result.shouldShowYearCreated && result.shouldShowYearSubmitted) {
if (result.shouldShowYearCreated && result.shouldShowYearSubmitted && result.shouldShowYearApproved && result.shouldShowYearPosted) {
return result;
}
}
Expand All @@ -931,6 +944,12 @@ function shouldShowYear(
if (report?.approved && DateUtils.doesDateBelongToAPastYear(report.approved)) {
result.shouldShowYearApproved = true;
}

// Posted date is in the YYYYMMDD format, so we extract the year manually here since JS's Date constructor interprets it as an invalid date.
if (item?.posted) {
Comment thread
luacmartins marked this conversation as resolved.
const postedYear = parseInt(item.posted.slice(0, 4), 10);
result.shouldShowYearPosted = postedYear !== currentYear;
}
} else if (!checkOnlyReports && isReportActionEntry(key)) {
const item = data[key];
for (const action of Object.values(item)) {
Expand All @@ -954,7 +973,7 @@ function shouldShowYear(
}

// Early exit if all flags are true
if (result.shouldShowYearCreated && result.shouldShowYearSubmitted) {
if (result.shouldShowYearCreated && result.shouldShowYearSubmitted && result.shouldShowYearApproved && result.shouldShowYearPosted) {
return result;
}
}
Expand Down Expand Up @@ -1111,7 +1130,7 @@ function getTransactionsSections(
isActionLoadingSet: ReadonlySet<string> | undefined,
): [TransactionListItemType[], number] {
const shouldShowMerchant = getShouldShowMerchant(data);
const {shouldShowYearCreated, shouldShowYearSubmitted, shouldShowYearApproved} = shouldShowYear(data);
const {shouldShowYearCreated, shouldShowYearSubmitted, shouldShowYearApproved, shouldShowYearPosted} = shouldShowYear(data);
const {shouldShowAmountInWideColumn, shouldShowTaxAmountInWideColumn} = getWideAmountIndicators(data);

// Pre-filter transaction keys to avoid repeated checks
Expand Down Expand Up @@ -1160,7 +1179,7 @@ function getTransactionsSections(
const from = reportAction?.actorAccountID ? (personalDetailsMap.get(reportAction.actorAccountID.toString()) ?? emptyPersonalDetails) : emptyPersonalDetails;
const to = getToFieldValueForTransaction(transactionItem, report, data.personalDetailsList, reportAction);

const {formattedFrom, formattedTo, formattedTotal, formattedMerchant, date, submitted, approved} = getTransactionItemCommonFormattedProperties(
const {formattedFrom, formattedTo, formattedTotal, formattedMerchant, date, submitted, approved, posted} = getTransactionItemCommonFormattedProperties(
transactionItem,
from,
to,
Expand All @@ -1187,10 +1206,12 @@ function getTransactionsSections(
date,
submitted,
approved,
posted,
shouldShowMerchant,
shouldShowYear: shouldShowYearCreated,
shouldShowYearSubmitted,
shouldShowYearApproved,
shouldShowYearPosted,
isAmountColumnWide: shouldShowAmountInWideColumn,
isTaxAmountColumnWide: shouldShowTaxAmountInWideColumn,
violations: transactionViolations,
Expand Down Expand Up @@ -1566,6 +1587,7 @@ function getReportSections(
shouldShowYearCreated: shouldShowYearCreatedTransaction,
shouldShowYearSubmitted: shouldShowYearSubmittedTransaction,
shouldShowYearApproved: shouldShowYearApprovedTransaction,
shouldShowYearPosted: shouldShowYearPostedTransaction,
} = shouldShowYear(data);
const {shouldShowAmountInWideColumn, shouldShowTaxAmountInWideColumn} = getWideAmountIndicators(data);
const {moneyRequestReportActionsByTransactionID, holdReportActionsByTransactionID} = createReportActionsLookupMaps(data);
Expand Down Expand Up @@ -1717,6 +1739,7 @@ function getReportSections(
shouldShowYear: shouldShowYearCreatedTransaction,
shouldShowYearSubmitted: shouldShowYearSubmittedTransaction,
shouldShowYearApproved: shouldShowYearApprovedTransaction,
shouldShowYearPosted: shouldShowYearPostedTransaction,
keyForList: transactionItem.transactionID,
violations: transactionViolations,
isAmountColumnWide: shouldShowAmountInWideColumn,
Expand Down Expand Up @@ -2209,6 +2232,8 @@ function getSearchColumnTranslationKey(columnId: SearchCustomColumnIds): Transla
return 'common.submitted';
case CONST.SEARCH.TABLE_COLUMNS.APPROVED:
return 'search.filters.approved';
case CONST.SEARCH.TABLE_COLUMNS.POSTED:
return 'search.filters.posted';
case CONST.SEARCH.TABLE_COLUMNS.MERCHANT:
return 'common.merchant';
case CONST.SEARCH.TABLE_COLUMNS.FROM:
Expand Down Expand Up @@ -2679,6 +2704,7 @@ function getColumnsToShow(
[CONST.SEARCH.TABLE_COLUMNS.DATE]: true,
[CONST.SEARCH.TABLE_COLUMNS.SUBMITTED]: false,
[CONST.SEARCH.TABLE_COLUMNS.APPROVED]: false,
[CONST.SEARCH.TABLE_COLUMNS.POSTED]: false,
[CONST.SEARCH.TABLE_COLUMNS.MERCHANT]: false,
[CONST.SEARCH.TABLE_COLUMNS.DESCRIPTION]: false,
[CONST.SEARCH.TABLE_COLUMNS.FROM]: false,
Expand Down Expand Up @@ -2890,7 +2916,7 @@ function getTableMinWidth(columns: SearchColumnType[]) {
minWidth += 80;
} else if (column === CONST.SEARCH.TABLE_COLUMNS.DATE) {
minWidth += 48;
} else if (column === CONST.SEARCH.TABLE_COLUMNS.SUBMITTED || column === CONST.SEARCH.TABLE_COLUMNS.APPROVED) {
} else if (column === CONST.SEARCH.TABLE_COLUMNS.SUBMITTED || column === CONST.SEARCH.TABLE_COLUMNS.APPROVED || column === CONST.SEARCH.TABLE_COLUMNS.POSTED) {
minWidth += 72;
} else if (column === CONST.SEARCH.TABLE_COLUMNS.TYPE) {
minWidth += 20;
Expand Down
4 changes: 4 additions & 0 deletions src/styles/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,7 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({
isDateColumnFullWidth = false,
isSubmittedColumnWide = false,
isApprovedColumnWide = false,
isPostedColumnWide = false,
): ViewStyle => {
let columnWidth;
switch (columnName) {
Expand All @@ -1745,6 +1746,9 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({
case CONST.SEARCH.TABLE_COLUMNS.APPROVED:
columnWidth = {...getWidthStyle(isApprovedColumnWide ? variables.w92 : variables.w72)};
break;
case CONST.SEARCH.TABLE_COLUMNS.POSTED:
columnWidth = {...getWidthStyle(isPostedColumnWide ? variables.w92 : variables.w72)};
break;
case CONST.SEARCH.TABLE_COLUMNS.DATE:
// We will remove this variable & param, but in a follow up PR. We are duplicating the logic here to "use" the variable
// to prevent eslint errors. This will be removed
Expand Down
Loading
Loading