Repository navigation
fixed truncated Posted column in Report layout table #95635
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
Changes from all commits
63c5590
150d5bb
dfd4786
52150ce
96bd3a9
17fcf94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,7 @@ import {compareValues, getColumnsToShow, getTableMinWidth, hasFlexColumn, isTran | |
| import {getPendingSubmitFollowUpAction} from '@libs/telemetry/submitFollowUpAction'; | ||
| import {transactionHasRBR} from '@libs/TransactionPreviewUtils'; | ||
| import {getTransactionPendingAction, getVisibleTransactionViolations, isTransactionPendingDelete, shouldShowExpenseBreakdown} from '@libs/TransactionUtils'; | ||
| import shouldShowTransactionPostedYear from '@libs/TransactionUtils/shouldShowTransactionPostedYear'; | ||
| import shouldShowTransactionYear from '@libs/TransactionUtils/shouldShowTransactionYear'; | ||
|
|
||
| import isReportOpenInSuperWideRHP from '@navigation/helpers/isReportOpenInSuperWideRHP'; | ||
|
|
@@ -571,14 +572,16 @@ function MoneyRequestReportTransactionList({ | |
| [navigateToTransactionThread, reportActions, sortedTransactions, report, visualOrderTransactionIDs], | ||
| ); | ||
|
|
||
| const {amountColumnSize, dateColumnSize, taxAmountColumnSize} = useMemo(() => { | ||
| const {amountColumnSize, dateColumnSize, postedColumnSize, taxAmountColumnSize} = useMemo(() => { | ||
| const isAmountColumnWide = transactions.some((transaction) => isTransactionAmountTooLong(transaction)); | ||
| const isTaxAmountColumnWide = transactions.some((transaction) => isTransactionTaxAmountTooLong(transaction)); | ||
| const shouldShowYearForSomeTransaction = transactions.some((transaction) => shouldShowTransactionYear(transaction)); | ||
| const shouldShowPostedYearForSomeTransaction = transactions.some((transaction) => shouldShowTransactionPostedYear(transaction)); | ||
| return { | ||
| 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, | ||
| dateColumnSize: shouldShowYearForSomeTransaction ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL, | ||
| postedColumnSize: shouldShowPostedYearForSomeTransaction ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When any posted date needs the wider 102px cell, this only widens the rendered header/rows; the report table still decides Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a pre-existing limitation of the date-column widening rather than something introduced here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Making |
||
| }; | ||
| }, [transactions]); | ||
|
|
||
|
|
@@ -722,6 +725,7 @@ function MoneyRequestReportTransactionList({ | |
| handleOnPress={handleOnPress} | ||
| handleLongPress={handleLongPress} | ||
| dateColumnSize={dateColumnSize} | ||
| postedColumnSize={postedColumnSize} | ||
| amountColumnSize={amountColumnSize} | ||
| taxAmountColumnSize={taxAmountColumnSize} | ||
| scrollToNewTransaction={transaction.transactionID === newTransactions?.at(0)?.transactionID ? scrollToNewTransaction : undefined} | ||
|
|
@@ -831,6 +835,7 @@ function MoneyRequestReportTransactionList({ | |
| shouldRemoveTotalColumnFlex={hasFlexColumn(columnsToShow)} | ||
| columns={columnsToShow} | ||
| dateColumnSize={dateColumnSize} | ||
| postedColumnSize={postedColumnSize} | ||
| amountColumnSize={amountColumnSize} | ||
| taxAmountColumnSize={taxAmountColumnSize} | ||
| onSortPress={(selectedSortBy, selectedSortOrder) => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| function getFormattedPostedDate(posted?: string): string { | ||
| if (!posted) { | ||
| return ''; | ||
| } | ||
| if (!/^\d{8}$/.test(posted)) { | ||
| return posted; | ||
| } | ||
| return `${posted.slice(0, 4)}-${posted.slice(4, 6)}-${posted.slice(6, 8)}`; | ||
| } | ||
|
|
||
| export default getFormattedPostedDate; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import DateUtils from '@libs/DateUtils'; | ||
|
|
||
| import type {OnyxInputOrEntry, Transaction} from '@src/types/onyx'; | ||
|
|
||
| import getFormattedPostedDate from './getFormattedPostedDate'; | ||
|
|
||
| function shouldShowTransactionPostedYear(transaction: OnyxInputOrEntry<Transaction>) { | ||
| const posted = transaction?.posted; | ||
| if (!posted) { | ||
| return false; | ||
| } | ||
| return DateUtils.doesDateBelongToAPastYear(getFormattedPostedDate(posted)); | ||
| } | ||
|
|
||
| export default shouldShowTransactionPostedYear; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import getFormattedPostedDate from '@libs/TransactionUtils/getFormattedPostedDate'; | ||
|
|
||
| describe('getFormattedPostedDate', () => { | ||
| it('converts a raw YYYYMMDD card posted date to YYYY-MM-DD', () => { | ||
| expect(getFormattedPostedDate('20260710')).toBe('2026-07-10'); | ||
| expect(getFormattedPostedDate('20251231')).toBe('2025-12-31'); | ||
| }); | ||
|
|
||
| it('passes an already-ISO date through unchanged (idempotent)', () => { | ||
| expect(getFormattedPostedDate('2026-07-10')).toBe('2026-07-10'); | ||
| }); | ||
|
|
||
| it('returns an empty string for empty/undefined input', () => { | ||
| expect(getFormattedPostedDate(undefined)).toBe(''); | ||
| expect(getFormattedPostedDate('')).toBe(''); | ||
| }); | ||
|
|
||
| it('passes any non-YYYYMMDD string through unchanged', () => { | ||
| expect(getFormattedPostedDate('2026-7-1')).toBe('2026-7-1'); | ||
| expect(getFormattedPostedDate('not-a-date')).toBe('not-a-date'); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import shouldShowTransactionPostedYear from '@libs/TransactionUtils/shouldShowTransactionPostedYear'; | ||
|
|
||
| import createRandomTransaction from '../utils/collections/transaction'; | ||
|
|
||
| const currentYear = new Date().getFullYear(); | ||
| const transactionWithPosted = (posted?: string) => ({...createRandomTransaction(0), posted}); | ||
|
|
||
| describe('shouldShowTransactionPostedYear', () => { | ||
| it('returns true when the raw YYYYMMDD posted date is in a past year', () => { | ||
| expect(shouldShowTransactionPostedYear(transactionWithPosted(`${currentYear - 1}0701`))).toBe(true); | ||
| }); | ||
|
|
||
| it('returns false when the raw YYYYMMDD posted date is in the current year', () => { | ||
| expect(shouldShowTransactionPostedYear(transactionWithPosted(`${currentYear}0701`))).toBe(false); | ||
| }); | ||
|
|
||
| it('returns false when there is no posted date', () => { | ||
| expect(shouldShowTransactionPostedYear(transactionWithPosted(undefined))).toBe(false); | ||
| expect(shouldShowTransactionPostedYear(transactionWithPosted(''))).toBe(false); | ||
| }); | ||
|
|
||
| it('returns false for a nullish transaction', () => { | ||
| expect(shouldShowTransactionPostedYear(undefined)).toBe(false); | ||
| expect(shouldShowTransactionPostedYear(null)).toBe(false); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For report-layout rows with raw card posted dates such as
20260710,TransactionItemRowWidepassestransactionItem.posteddirectly toDateCell;DateCellchooses the year format throughDateUtils.doesDateBelongToAPastYear, whosenew Date('YYYYMMDD')path yieldsNaNand therefore selects the year format even for current-year values. This new size predicate returns false for current-year posted dates, so those rows still renderMMM d, yyyyin the normal 62px Posted column and remain truncated. Consider matching the renderer's predicate or normalizing posted dates before sizing/rendering.Useful? React with 👍 / 👎.