@@ -8355,6 +8355,82 @@ describe('SearchUIUtils', () => {
83558355 expect ( columns ) . toContain ( CONST . SEARCH . TABLE_COLUMNS . TAX_AMOUNT ) ;
83568356 } ) ;
83578357
8358+ test ( 'Should show TAX columns when user selected them and the workspace has taxes enabled, even for transactions with null tax fields' , ( ) => {
8359+ // Repro for the issue raised on GH #82252: expenses created before taxes were
8360+ // enabled have null taxCode/taxAmount/taxValue and never get backfilled, so the
8361+ // per-transaction check alone would hide the columns even though the user has
8362+ // both selected the columns and enabled taxes on the workspace.
8363+ const baseTransaction = searchResults . data [ `transactions_${ transactionID } ` ] ;
8364+ const legacyTransaction = {
8365+ ...baseTransaction ,
8366+ transactionID : 'legacy' ,
8367+ merchant : 'Legacy Expense' ,
8368+ taxCode : undefined ,
8369+ taxAmount : undefined ,
8370+ } ;
8371+ const visibleColumns = [ CONST . SEARCH . TABLE_COLUMNS . DATE , CONST . SEARCH . TABLE_COLUMNS . TAX_RATE , CONST . SEARCH . TABLE_COLUMNS . TAX_AMOUNT , CONST . SEARCH . TABLE_COLUMNS . TOTAL_AMOUNT ] ;
8372+ const columns = SearchUIUtils . getColumnsToShow ( {
8373+ currentAccountID : submitterAccountID ,
8374+ data : [ legacyTransaction ] ,
8375+ visibleColumns,
8376+ isExpenseReportView : true ,
8377+ isPolicyTaxEnabled : true ,
8378+ } ) ;
8379+
8380+ expect ( columns ) . toContain ( CONST . SEARCH . TABLE_COLUMNS . TAX_RATE ) ;
8381+ expect ( columns ) . toContain ( CONST . SEARCH . TABLE_COLUMNS . TAX_AMOUNT ) ;
8382+ } ) ;
8383+
8384+ test ( 'Should NOT inject TAX columns when the workspace has taxes enabled but the user did not select them' , ( ) => {
8385+ // Guard: enabling taxes on the workspace must not force the columns into the
8386+ // result if the user deselected them in the column selector. The customResult
8387+ // path filters to the user's selection, so unselected columns stay hidden even
8388+ // when columns[TAX_RATE]/[TAX_AMOUNT] get flipped on internally.
8389+ const baseTransaction = searchResults . data [ `transactions_${ transactionID } ` ] ;
8390+ const legacyTransaction = {
8391+ ...baseTransaction ,
8392+ transactionID : 'legacy' ,
8393+ merchant : 'Legacy Expense' ,
8394+ taxCode : undefined ,
8395+ taxAmount : undefined ,
8396+ } ;
8397+ const visibleColumns = [ CONST . SEARCH . TABLE_COLUMNS . DATE , CONST . SEARCH . TABLE_COLUMNS . MERCHANT , CONST . SEARCH . TABLE_COLUMNS . TOTAL_AMOUNT ] ;
8398+ const columns = SearchUIUtils . getColumnsToShow ( {
8399+ currentAccountID : submitterAccountID ,
8400+ data : [ legacyTransaction ] ,
8401+ visibleColumns,
8402+ isExpenseReportView : true ,
8403+ isPolicyTaxEnabled : true ,
8404+ } ) ;
8405+
8406+ expect ( columns ) . not . toContain ( CONST . SEARCH . TABLE_COLUMNS . TAX_RATE ) ;
8407+ expect ( columns ) . not . toContain ( CONST . SEARCH . TABLE_COLUMNS . TAX_AMOUNT ) ;
8408+ } ) ;
8409+
8410+ test ( 'Should hide TAX columns when the workspace does not have taxes enabled and transactions have no tax data' , ( ) => {
8411+ // Regression guard: without a tax-enabled policy and without per-transaction tax
8412+ // data, the columns must stay hidden even if the user selected them.
8413+ const baseTransaction = searchResults . data [ `transactions_${ transactionID } ` ] ;
8414+ const legacyTransaction = {
8415+ ...baseTransaction ,
8416+ transactionID : 'legacy' ,
8417+ merchant : 'Legacy Expense' ,
8418+ taxCode : undefined ,
8419+ taxAmount : undefined ,
8420+ } ;
8421+ const visibleColumns = [ CONST . SEARCH . TABLE_COLUMNS . DATE , CONST . SEARCH . TABLE_COLUMNS . TAX_RATE , CONST . SEARCH . TABLE_COLUMNS . TAX_AMOUNT , CONST . SEARCH . TABLE_COLUMNS . TOTAL_AMOUNT ] ;
8422+ const columns = SearchUIUtils . getColumnsToShow ( {
8423+ currentAccountID : submitterAccountID ,
8424+ data : [ legacyTransaction ] ,
8425+ visibleColumns,
8426+ isExpenseReportView : true ,
8427+ isPolicyTaxEnabled : false ,
8428+ } ) ;
8429+
8430+ expect ( columns ) . not . toContain ( CONST . SEARCH . TABLE_COLUMNS . TAX_RATE ) ;
8431+ expect ( columns ) . not . toContain ( CONST . SEARCH . TABLE_COLUMNS . TAX_AMOUNT ) ;
8432+ } ) ;
8433+
83588434 test ( 'Should hide empty AMOUNT column in expense report view when no conversion' , ( ) => {
83598435 const baseTransaction = searchResults . data [ `transactions_${ transactionID } ` ] ;
83608436 const testTransaction = {
0 commit comments